我有一个jquery-ajax
函数,它创建了一个复选框列表。jquery复选框使用JSON创建的点击功能不起作用
success: function(msg){
jQuery.each(msg.gal_sublocations, function(index, gal_sublocation) {
html += '<input type="checkbox" name="data[GalStore][gal_sublocation_id][]" value = "'+gal_sublocation.GalSublocation.id+'" class="chkbx" id="sublocation_'+gal_sublocation.GalSublocation.id+'" />'+gal_sublocation.GalSublocation.name;
$('#load_sublocations').html(html);
alert(html);
$('#sublocation_'+gal_sublocation.GalSublocation.id).click(function(){
alert('Checked !');
});
});
}
的alert(html)
产生最终的警觉
<input type="checkbox" name="data[GalStore][gal_sublocation_id][]" value = "99" class="chkbx" id="sublocation_99" />Beltola
<input type="checkbox" name="data[GalStore][gal_sublocation_id][]" value = "101" class="chkbx" id="sublocation_101" />Dispur
<input type="checkbox" name="data[GalStore][gal_sublocation_id][]" value = "102" class="chkbx" id="sublocation_102" />Paltan Bazar
<input type="checkbox" name="data[GalStore][gal_sublocation_id][]" value = "100" class="chkbx" id="sublocation_100" />Patarkuchi
但是当我点击复选框,它没有任何警告!怎么了 ?
喜Mehmet..it还没有工作!相同。只有最后一个复选框工作! – Nitish