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 :

http://s8.postimg.org/nqwv1na6d/js_function.png

http://s1.postimg.org/mqyu5zalr/js_function.png

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

Popular posts from this blog

c# - How to get the current UAC mode -

angularjs - ng-repeat duplicating items after page reload -

javascript - What's causing this slow/delayed audio playback in Safari? -