snipt

Ctrl+h for KB shortcuts

JavaScript

Toggle checkbox with jQuery

$('#id').attr('checked', !$('#id').attr('checked'));
https://snipt.net/embed/b42c4d6d5afbc4255849107c0486303b/
https://snipt.net/raw/b42c4d6d5afbc4255849107c0486303b/
b42c4d6d5afbc4255849107c0486303b
js
JavaScript
2
2016-09-21T16:55:52
True
False
False
/api/public/snipt/42623/
toggle-checkbox-with-jquery
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;checked&#39;</span><span class="p">,</span> <span class="o">!</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;checked&#39;</span><span class="p">));</span> </span></pre></div> </td></tr></table>
checkbox, jquery

JavaScript

Toggle all checkboxes on page

javascript:var%20fR=document.getElementsByTagName('frame');if(fR.length%3E0)for(f=0;f%3CfR.length;f++)%7Bvar%20eL=top.frames%5Bf%5D.document.getElementsByTagName('input');for(i=0;i%3CeL.length;i++)%7Bif(eL%5Bi%5D.checked==false)void(eL%5Bi%5D.checked=true);else%7Bvoid(eL%5Bi%5D.checked=false);%7D%7D%7Delse%7Bvar%20eL=document.getElementsByTagName('input');for(i=0;i%3CeL.length;i++)%7Bif(eL%5Bi%5D.checked==false)void(eL%5Bi%5D.checked=true);else%7Bvoid(eL%5Bi%5D.checked=false);%7D%7D%7D
https://snipt.net/embed/ecdb47168c90c5ca560251fac6e25a17/
https://snipt.net/raw/ecdb47168c90c5ca560251fac6e25a17/
ecdb47168c90c5ca560251fac6e25a17
js
JavaScript
1
2016-09-28T18:32:00
True
False
False
/api/public/snipt/14512/
toggle-all-checkboxes-on-page
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nx">javascript</span><span class="o">:</span><span class="kd">var</span><span class="o">%</span><span class="mi">20</span><span class="nx">fR</span><span class="o">=</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">&#39;frame&#39;</span><span class="p">);</span><span class="k">if</span><span class="p">(</span><span class="nx">fR</span><span class="p">.</span><span class="nx">length</span><span class="o">%</span><span class="mi">3</span><span class="nx">E0</span><span class="p">)</span><span class="k">for</span><span class="p">(</span><span class="nx">f</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="nx">f</span><span class="o">%</span><span class="mi">3</span><span class="nx">CfR</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="nx">f</span><span class="o">++</span><span class="p">)</span><span class="o">%</span><span class="mi">7</span><span class="nx">Bvar</span><span class="o">%</span><span class="mi">20</span><span class="nx">eL</span><span class="o">=</span><span class="nx">top</span><span class="p">.</span><span class="nx">frames</span><span class="o">%</span><span class="mi">5</span><span class="nx">Bf</span><span class="o">%</span><span class="mi">5</span><span class="nx">D</span><span class="p">.</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">&#39;input&#39;</span><span class="p">);</span><span class="k">for</span><span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="nx">i</span><span class="o">%</span><span class="mi">3</span><span class="nx">CeL</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="o">%</span><span class="mi">7</span><span class="nx">Bif</span><span class="p">(</span><span class="nx">eL</span><span class="o">%</span><span class="mi">5</span><span class="nx">Bi</span><span class="o">%</span><span class="mi">5</span><span class="nx">D</span><span class="p">.</span><span class="nx">checked</span><span class="o">==</span><span class="kc">false</span><span class="p">)</span><span class="k">void</span><span class="p">(</span><span class="nx">eL</span><span class="o">%</span><span class="mi">5</span><span class="nx">Bi</span><span class="o">%</span><span class="mi">5</span><span class="nx">D</span><span class="p">.</span><span class="nx">checked</span><span class="o">=</span><span class="kc">true</span><span class="p">);</span><span class="k">else</span><span class="o">%</span><span class="mi">7</span><span class="nx">Bvoid</span><span class="p">(</span><span class="nx">eL</span><span class="o">%</span><span class="mi">5</span><span class="nx">Bi</span><span class="o">%</span><span class="mi">5</span><span class="nx">D</span><span class="p">.</span><span class="nx">checked</span><span class="o">=</span><span class="kc">false</span><span class="p">);</span><span class="o">%</span><span class="mi">7</span><span class="nx">D</span><span class="o">%</span><span class="mi">7</span><span class="nx">D</span><span class="o">%</span><span class="mi">7</span><span class="nx">Delse</span><span class="o">%</span><span class="mi">7</span><span class="nx">Bvar</span><span class="o">%</span><span class="mi">20</span><span class="nx">eL</span><span class="o">=</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">&#39;input&#39;</span><span class="p">);</span><span class="k">for</span><span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="nx">i</span><span class="o">%</span><span class="mi">3</span><span class="nx">CeL</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="o">%</span><span class="mi">7</span><span class="nx">Bif</span><span class="p">(</span><span class="nx">eL</span><span class="o">%</span><span class="mi">5</span><span class="nx">Bi</span><span class="o">%</span><span class="mi">5</span><span class="nx">D</span><span class="p">.</span><span class="nx">checked</span><span class="o">==</span><span class="kc">false</span><span class="p">)</span><span class="k">void</span><span class="p">(</span><span class="nx">eL</span><span class="o">%</span><span class="mi">5</span><span class="nx">Bi</span><span class="o">%</span><span class="mi">5</span><span class="nx">D</span><span class="p">.</span><span class="nx">checked</span><span class="o">=</span><span class="kc">true</span><span class="p">);</span><span class="k">else</span><span class="o">%</span><span class="mi">7</span><span class="nx">Bvoid</span><span class="p">(</span><span class="nx">eL</span><span class="o">%</span><span class="mi">5</span><span class="nx">Bi</span><span class="o">%</span><span class="mi">5</span><span class="nx">D</span><span class="p">.</span><span class="nx">checked</span><span class="o">=</span><span class="kc">false</span><span class="p">);</span><span class="o">%</span><span class="mi">7</span><span class="nx">D</span><span class="o">%</span><span class="mi">7</span><span class="nx">D</span><span class="o">%</span><span class="mi">7</span><span class="nx">D</span> </span></pre></div> </td></tr></table>
bookmarklet, checkbox, dom, favelet, form, javascript, js, toggle
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.