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

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -