jQuery: How to collect values from sliders into simple object with id as keys
Posted
by Svish
on Stack Overflow
See other posts from Stack Overflow
or by Svish
Published on 2010-06-12T22:55:22Z
Indexed on
2010/06/12
23:02 UTC
Read the original article
Hit count: 217
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?
© Stack Overflow or respective owner