[jQuery] Re: Iterate through elements of a given class and multiply

2009-10-14 Thread James
Oh, another method is to store the default values as a Javascript array/object with a matching ID of the DIV. For example: var defaults = { 'div1': 100, 'div2': 200 } 100 200 alert( defaults['div1'] ); // alerts '100' On Oct 14, 8:29 am, Avik Basu wrote: > Thanks for your help--using .text

[jQuery] Re: Iterate through elements of a given class and multiply

2009-10-14 Thread James
You can store the original inside the element as an attribute. There are several ways you can do this. Here are the popular methods: One method is using the jQuery data() function: http://docs.jquery.com/Core/data However, this would require you to add the data via Javascript, which maybe not wh

[jQuery] Re: Iterate through elements of a given class and multiply

2009-10-14 Thread Avik Basu
Thanks for your help--using .text() solved the scaling problem. A related problem is how can I go back to the original values in the divs when scaling multiple times? Right now the behavior is such that it scales the div values properly the first time, but the second time it scales the already s

[jQuery] Re: Iterate through elements of a given class and multiply

2009-10-13 Thread mike.helgeson
parseFloat( $( this ).text() ) // divs don't have a value On Oct 13, 4:07 pm, Avik Basu wrote: > I would like to use JQuery to iterate through a set of elements > that have the same class and scale each value according to a value > selected from a dropdown box.  For example, > > > 1 > 2 > 3 >

[jQuery] Re: Iterate through elements of a given class and multiply

2009-10-13 Thread James
If it's a div, val() will not get you anything. Use text(). $("#factor").change(function() { var val = this.value; // value of select $(".num").each(function() { $(this).text( parseInt($(this).text()) * parseInt(val) ); }); }); On Oct 13, 10:07 am, Avik Basu wrote: > I woul