jQuery: How to collect values from sliders into simple object with id as keys
- by Svish
I have several jQuery UI Sliders and I want to collect their values. Thought it would be a simple task, but when I was going to do it I got stuck and not quite sure what to do anymore :p
The object I would like to end up with should look something like this:
{
a: 80,
b: 90,
c: 20,
...
}
I can do it manually like this:
var values = {
a: $('#a').slider('value'),
b: $('#b').slider('value'),
c: $('#c').slider('value'),
...
};
But that's a bit tedious, especially if I need to add or remove or rename. Was hoping I could do something with the map or each function or something like that, but I can't figure it out. Anyone have some clever ideas?