I have exhausted my research on using .one () for my needs and made it work correctly for an instance of the class selector, where it is displayed only once. But on jQuery.com it is indicated that the following will work, and if you click once, it will not start again if another item with the same class selector is clicked. However, this does not work for me. I have and need the same specific class selector on the same page.
Here is the code that jQuery.com gives as an example:
$("#foo").one("click", function() { alert("This will be displayed only once."); }); $("body").one("click", ".foo", function() { alert("This displays once for the first .foo clicked in the body."); });
the second above does not seem to work, as they say. Does anyone know how to actually make this work. Where can I have .foo in several places, but the function shows only once, after clicking on one of .foo. And when another .foo is clicked, it will no longer run this function? Thanks so much for any help / suggestions.
source share