event handling - jquery click handler -
I dynamically create a bunch of tags, add them to one and then add a click handler. .
code to add. Nav ("# nav a") to .ready (function () {// ... & lt; a & gt; Click the tag (function (event) {alert ('clicked' + event.target.id); return false;});});
If I have 10 tags as a result of this and click on the first one, I get 10 (ten!) Alerts - but all the tags I actually click on to be the ID Show. / P>
(If I click on the 5th tag, yes, I get 5 alerts - with the ID of all the 5th tag ...)
What's going on here? Is it because I created the tag dynamically?
Try it instead:
thanks
/ P>
$ (document) .ready (function () {/ * ... add code to AND div & lt; a & gt; tag. * / $ ("# Nav ("function") (function () {$ (this). (Function (e) {warning ('click' + e.target.id); return false;});});});
Anyway, these two are equal! There is no problem with your code. Check the tag generating code for the bug.
Comments
Post a Comment