$(function () { $("#chk1").change(function () { var chk = $(this); $("#msg").html( ".attr('checked'):" + chk.attr("checked") + "<br/>" + ".attr('readonly'):" + chk.attr("readonly") + "<br/>" + ".attr('disabled'):" + chk.attr("disabled") + "<br/>" + ".attr('selected'):" + chk.attr("selected") + "<br/><br/>" + ".prop('checked'):" + chk.prop("checked") + "<br/>" + ".prop('readonly'):" + chk.prop("readonly") + "<br/>" + ".prop('disabled'):" + chk.prop("disabled") + "<br/>" + ".prop('selected'):" + chk.prop("selected") + "<br/><br/>" + ".is('checked'):" + chk.is(":checked") + "<br/>" + ".is('disabled'):" + chk.is(":disabled") + "<br/>" + ".is('selected'):" + chk.is(":selected")); }); $("#Btn_Checked").click(function () { $("#chk1").prop("checked", function (i, val) { return !val; }).change(); }); $("#Btn_Readonly").click(function () { $("#chk1").prop("readonly", function (i, val) { return !val; }).change(); }); $("#Btn_Disabled").click(function () { $("#chk1").prop("disabled", function (i, val) { return !val; }).change(); }); $("#Btn_Selected").click(function () { $("#chk1").prop("selected", function (i, val) { return !val; }).change(); }); });
<input type="checkbox" id="chk1" value="123" /> <input id="Btn_Checked" type="button" value="Checked" /> <input id="Btn_Readonly" type="button" value="Readonly" /> <input id="Btn_Disabled" type="button" value="Disabled" /> <input id="Btn_Selected" type="button" value="Selected" /> <div id="msg"></div>