Say that you have just appended an element in JQuery and need to access it. Since your element was non-existent on the page load, you will need to refer the click on an upper existing element with this syntax:
This way, JQuery will access your element regardless it was existent or not on page load.
1 2 3 4 5 6 | $(document).on("click", ".targetclass", function(e){ //targetclass is the class of the element you intend to access e.preventDefault(); //do stuff here }); |
This way, JQuery will access your element regardless it was existent or not on page load.