javascript - How do I make dynamically inserted html objects clickable? -
so far have:
function createlink(text, parentelement) { var = document.createelement('p'); $( parentelement ).on( 'click', 'a', function () { gomainmenufromresults();}); var linktext = document.createtextnode(text); a.appendchild(linktext); temp1 = text.replace("/","-"); parentelement.appendchild(a); var br = document.createelement('br'); parentelement.appendchild(br); }
but on clicking element dynamically made nothing happens!
before:
$( parentelement ).on( 'click', 'a', function () { gomainmenufromresults();});
after:
$( parentelement ).on( 'click', 'p', function () { gomainmenufromresults();});
Comments
Post a Comment