i have following function calling after ajax completes:
function name(results) { var str=''; str+='<div id="newdiv"></div>'; str+='<input type="text" value="'+results.name+'" id="newtextbox"></input>'; $('#otherdiv').html(str); } then used newdiv , newtextbox like
$('#newdiv').html('example text'); it works me. when use
$('#newtextbox').click(function(){ alert('click without live'); }); it not working. changed to:
$('#newtextbox').live("click",function(){ alert('click live'); }); then working me.
my question both (newdiv, newtextbox) created dynamically.
why $('#newdiv').html('example text'); working without using live, click event not working newtextbox?
as question, want tell :
a string containing javascript event type, such "click" or "keydown." of jquery string can contain multiple, space-separated event types or custom event names.
here .click event , .html not event.
so .html function working without using .live function .click event bind selectors , created dynamically that's why need use .live or .on function bind event.
Comments
Post a Comment