hello -
i currently have this code:
- jQuery('div.One').bind('click', function() { myFunction(1); });
- jQuery('div.Two').bind('click', function() { myFunction(2); });
- jQuery('div.Three').bind('click', function() { myFunction(3); });
this works
great, as does this method (probably the same thing)
- jQuery('div.One').click(function() { myFunction(1); });
- jQuery('div.Two').click(function() { myFunction(2); });
i am currently trying to put these values into a object and loop through it like so:
- var marksObject =
- ( 'One' : 1
- , 'Two' : 2
- , 'Three' : 3
- };
- for ( key in marksObject ) {
- className = 'div.' + key;
- idNbr = marksObject[key];
- jQuery(className).bind('click', function() { myFunction(idNbr); });
- }
my problem is that EVERY div ends up being bound to the LAST entry in marksObject.
in other words, "div.One", "div.Two", and "div.Three" all end up binded using a value of 3.
i suspect there is an easy solution or workaround to this.
thank you all very much.