| Author |
jQuery - unable to obtain slider values from wrapped set of sliders
|
Joe Lemmer
Ranch Hand
Joined: Oct 24, 2008
Posts: 171
|
|
Hi there,
I have some jQuery sliders on a web page and I want to get their values and store those values in an Array.
I didn't think this would be a problem as I having been getting the slider values no problem when I have been accessing them as follows:
So I thought the best way to get all the values would be to get a wrapped set of all the sliders and then iterate through this and get all the values as follows:
but it's not working. I've used alerts to debug, and it's the code in the for loop that is the problem. As far as I can see, this code is getting a wrapped set of divs with class 'slider', getting the one at the index of 'i', getting the value of the slider and assigning it to the correct element of the array.
I have used $('div.slider').size() to see that the wrapped set had elements to it and it did, so I am very confused and wonder if anybody can point me in the right direction.
Thank you in advance.
Joe
|
OCPJP 85%
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56533
|
|
You're kinda doing it inside out.
Rather than apply the loop from the "outside", investigate the use of jQuery's .each() method.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56533
|
|
|
(and even more relevant to your situation, jQuery's .map() method).
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15362
|
|
get() does not return a jQuery object, it returns the DOM Object
secondly you are getting the value wrong.
http://docs.jquery.com/UI/Slider#methods
Eric
|
 |
Joe Lemmer
Ranch Hand
Joined: Oct 24, 2008
Posts: 171
|
|
Hi Bear and Eric,
Thank you. I found both your replies very helpful and have fixed my problem as a result. I have now have the following (I think) pretty nice code:
Sweet!
Thanks again
Joe
|
 |
 |
|
|
subject: jQuery - unable to obtain slider values from wrapped set of sliders
|
|
|