javascript - How to process click event of dynamically created hyperlinks? -


i have dynamically generated links

<a name="details" id="1" href="javascript:;">details</a>

when 1 of them clicked want process event javascript code this

$(document).ready(function () {     var = document.getelementsbyname('details').item(0);      a.on('click', function () {         $.ajax({             ///         });     }); }); 

however, though seems find hyperlinks quite perfectly, on click event doesn't enter function.

what wrong implementation?

on method find on jquery objects.

document.getelementsbyname('details').item(0) returns native dom element.

either use addeventlistener instead of on or $("some selector") instead of getelementsbyname & item.


Comments

Popular posts from this blog

ios - Is 'init' forbidden as *part* of a variable name? -

angular - Angular2 Router: Cannot find primary outlet to load 'HomeComponent' -

qt - Microsoft FTP Service 451 The parameter is incorrect -