javascript - jQuery: Accessing Elements after adding them with Append -
this question has answer here:
i append input in div:
$("#menuitems").append("<input type='button' id='"+$("#category").val()+"' class='menuitemdelete' value="+$("#category :selected").text()+" ><br>");
then want access element class name not give responce. try this:
$(".menuitemdelete").click(function(){ alert("abc"); });
and try this:
$(".menuitemdelete").on("click", function(){ alert("abc"); });
how can access ?
try :
$("#menuitems").on("click",'.menuitemdelete', function(){ alert("abc"); });
consider read event delegation concept dynamic element created yours.
Comments
Post a Comment