Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is the most up-to-date solution.</p> <pre><code>&lt;form name="frmChkForm" id="frmChkForm"&gt; &lt;input type="checkbox" name="chkcc9" id="group1" /&gt;Check Me &lt;input type="checkbox" name="chk9[120]" class="group1" /&gt; &lt;input type="checkbox" name="chk9[140]" class="group1" /&gt; &lt;input type="checkbox" name="chk9[150]" class="group1" /&gt; &lt;/form&gt; $(function() { enable_cb(); $("#group1").click(enable_cb); }); function enable_cb() { $("input.group1").prop("disabled", !this.checked); } </code></pre> <hr> <p>Here is the usage details for <code>.attr()</code> and <code>.prop()</code>.</p> <h2>jQuery 1.6+</h2> <p>Use the new <a href="http://api.jquery.com/prop/#entry-longdesc-1" rel="noreferrer"><code>.prop()</code></a> function:</p> <pre><code>$("input.group1").prop("disabled", true); $("input.group1").prop("disabled", false); </code></pre> <h2>jQuery 1.5 and below</h2> <p>The <code>.prop()</code> function is not available, so you need to use <code>.attr()</code>.</p> <p>To disable the checkbox (by setting the value of the disabled attribute) do</p> <pre><code>$("input.group1").attr('disabled','disabled'); </code></pre> <p>and for enabling (by removing the attribute entirely) do</p> <pre><code>$("input.group1").removeAttr('disabled'); </code></pre> <h2>Any version of jQuery</h2> <p>If you're working with just one element, it will always be fastest to use <code>DOMElement.disabled = true</code>. The benefit to using the <code>.prop()</code> and <code>.attr()</code> functions is that they will operate on all matched elements.</p> <pre><code>// Assuming an event handler on a checkbox if (this.disabled) </code></pre> <p>ref: <a href="https://stackoverflow.com/questions/426258/how-do-i-check-a-checkbox-with-jquery">Setting &quot;checked&quot; for a checkbox with jQuery?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload