Binding event to element dynamically
- for (x=0;x<=10;x++) {
- var tempID = 'elementName' + x;
- $(jq_escape(tempID)).bind('dblclick',function(event) {
- alert(tempID);
- });
- }
Double-clicking on any of the element will give me an alert message "
elementName10" instead of
elementName0 through
elementName10.
Does the same thing if I tried $(.selector).dblclick(...).
Any idea why?
Thanks,
Harison