selecting all checkboxes in jquery -
i want select checkboxes of specific name checking single checkbox on page , trigger subsequent events.
as have @ moment doesnt seem fire immediately, upon first checking of 'select all' checkbox checkboxes not selected , unchecking 'select all' check box checkboxes checked.
seems bit upside down.
how can improve following code works properly?
$(document).on("click", "input[name='chkallbs']", function () { if ($('input[name = chkbestseller]').prop('checked') == false) { $('input[name=chkbestseller]').attr("checked", "true"); $('input[name=chkbestseller]').trigger('click'); } else { $('input[name=chkbestseller]').attr("checked", "false"); $('input[name=chkbestseller]').trigger('click'); }
it like
if ($('input[name = chkbestseller]').prop('checked') == true) { $('input[name=chkbestseller]').attr("checked", true); } else { $('input[name=chkbestseller]').attr("checked", false); }
or
$(document).on("click", "input[name='chkallbs']", function () { $('input[name="chkbestseller"]').prop("checked", this.checked); });
Comments
Post a Comment