javascript - jQuery functions not working after JS innerHTML property -


i using code in application:

document.getelementbyid("inventory_box").innerhtml = "<img src='./img/rock.gif' id='test' />"; 

the #inventory_box element present already, spews out img #inventory_box.

what want able click appeared img id name test, won't work like:

$("#test").click(function() {                 // run             }); 

try this,

$(document).on('click',"#test",function() {     alert('test'); }); 

read on()


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -