I have tree type of checkbox which class is named checkAll,checkRow,checkCell
in my grid.When I click checkAll
checkbox ,all the checkbox will be checked.When I click the checkRow
checkbox,the checkbox in this row will be checked. Now I use the same code to create checkAll,checkRow
event,I find checkAll' event work well,but in
checkRow` event it is wrong.It says Jscript error.And I try to change it use juqery way and it works well.What is the differece between my codes when find checkbox in IE8?
First way:checkAll works well,checkRow do not work
$("#checkAll").on("click", function (e) {
var target = $(e.target), item, checked = target.prop("checked"),
checkboxes = $("#Grid input");
checkboxes.each(function (i, v) {
item = $(v);
if(!item.prop("disabled"))
item.prop("checked", checked);
});
});
$("#Grid").on("click", ".checkRow", function (e) {
var target = $(e.target), checked = target.prop("checked"),
td = target.parent("td"), tr = td.parent("tr"),
checkboxes = tr.find("input[class!='checkRow']");
checkboxes.each(function (i, v) {
item = $(v); //in this row Jscript error,wrong property in IE8,but firfox work well
item.prop("checked", checked);
});
});
Second way in checkrow event and work well
$("#Grid").on("click", ".checkRow", function (e) {
var target = $(e.target), checked = target.prop("checked"),
td = target.parent("td"), tr = td.parent("tr"),
checkboxes = tr.find("input[class!='checkRow']");
checkboxes.prop("checked", checked);//work well
});
Aucun commentaire:
Enregistrer un commentaire