snipt

Ctrl+h for KB shortcuts

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/
/raw/ecdb47168c90c5ca560251fac6e25a17/
ecdb47168c90c5ca560251fac6e25a17
js
JavaScript
1
2019-06-17T18:54:42
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></span><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

JavaScript

jQuery poistion among siblings

1
2
3
4
5
6
7
$('div').click(function() {
    // Will give you the index out of just the DIV tags
    var index = $(this).parent().find('> ' + this.tagName).index(this);

    // Will give you the index out of all siblings
    var index = $(this).parent().find('> *').index(this);
});
https://snipt.net/embed/c1bfdf3e7eb89e6717e92b1cb4aaa6af/
/raw/c1bfdf3e7eb89e6717e92b1cb4aaa6af/
c1bfdf3e7eb89e6717e92b1cb4aaa6af
js
JavaScript
7
2019-06-14T17:03:04
True
False
False
/api/public/snipt/5483/
jquery-poistion-among-siblings
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;div&#39;</span><span class="p">).</span><span class="nx">click</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="c1">// Will give you the index out of just the DIV tags</span> </span><span id="L-3"><a name="L-3"></a> <span class="kd">var</span> <span class="nx">index</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">parent</span><span class="p">().</span><span class="nx">find</span><span class="p">(</span><span class="s1">&#39;&gt; &#39;</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">tagName</span><span class="p">).</span><span class="nx">index</span><span class="p">(</span><span class="k">this</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a> <span class="c1">// Will give you the index out of all siblings</span> </span><span id="L-6"><a name="L-6"></a> <span class="kd">var</span> <span class="nx">index</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">parent</span><span class="p">().</span><span class="nx">find</span><span class="p">(</span><span class="s1">&#39;&gt; *&#39;</span><span class="p">).</span><span class="nx">index</span><span class="p">(</span><span class="k">this</span><span class="p">);</span> </span><span id="L-7"><a name="L-7"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
"jonathan sharp", "next to", dom, index, jquery, number, place, position