jquery - call a javascript function within dynamically created html -
i have java script file you'll see in picture below .
in file create html code webpage , , in html call function defined in java script file . when run function isn't defined .
additional info :
plus function mentioned ("cbutton") defined in function inside java script file.
(function () { var thecid = 0; function cbutton (ii) { document.getelementbyid(ii).style.display = 'none'; alert('fdgfg'); } $("#subber").on("click", function () { var thelm = "#c0"+thecid; var newcommhtml = '<div id="c0' + thecid + '" class="cnew clearfix">'; var ii='c0'+thecid; newcommhtml += '<section class="c-content">'; newcommhtml += '<a href="#" onclick="cbutton(\'' + ii + '\');" style="color:black;">x</a>'; newcommhtml += '<p>' + nl2br(textval) + '</p> </section></div>'; }); })()
for onclick
work, need cbutton()
accessible globally property of global window object.
change code to:
window.cbutton = function(ii) { ... }
Comments
Post a Comment