javascript - Append jQuery working but onclick is not working -



javascript - Append jQuery working but onclick is not working -

this question has reply here:

event binding on dynamically created elements? 13 answers

i have filter producttypes getting created per enteries in database via ajax:

html part:

<ul id="foodtype"></ul>

ajax code show filter:

function showtypes(){ $.ajax({ type: "post", url: "ajax/incl/showtype", data:'', datatype : 'json', cache: false, success: function(records1){ $('#foodtype').html(makefoodtype(records1)); } }); } function makefoodtype(data1){ var tbl_body = ""; $.each(data1, function() { var tbl_row = "", currrecord = this; $.each(this, function(k1 , v1) { tbl_row += "<li><input type=checkbox id="+v1+" name="+v1+" /> <span style=font-size:14px>"+v1+"</span></li>"; }) tbl_body += tbl_row; }) homecoming tbl_body; }

the categories getting displayed when select checkbox next code needs executed

function getfilteroptions(){ var opts = [d,de]; $checkboxes.each(function(){ if(this.checked){ opts.push(this.id); } homecoming opts; } var $checkboxes = $("input:checkbox"); $checkboxes.on("change", function(){ var opts = getfilteroptions(); updateproducts(opts); });

i want id of checkbox pushed page having php code. nil happening on checking checkbox. note: when view source code <ul id="foodtype"></ul> code remains inact.. no <li> elements displayed :(

you need utilize called event delegation. hear on click events on container checkboxes are. after add together them dynamically, click event bubbled container.

javascript php jquery ajax

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -