Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

JavaScript

jquery filter elements and act on them

1
2
3
4
$('*').filter(function () { return $(this).css('display') == "none" }).remove();


$('span').filter(function () { return $(this).text() == "" }).remove();
https://snipt.net/embed/916469188b4522db5530fb79ae593038/
https://snipt.net/raw/916469188b4522db5530fb79ae593038/
916469188b4522db5530fb79ae593038
js
JavaScript
4
2016-12-07T02:51:49
True
False
False
Dec 09, 2015 at 07:42 PM
/api/public/snipt/142947/
jquery-filter-elements-and-act-on-them
<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></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;*&#39;</span><span class="p">).</span><span class="nx">filter</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">css</span><span class="p">(</span><span class="s1">&#39;display&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s2">&quot;none&quot;</span> <span class="p">}).</span><span class="nx">remove</span><span class="p">();</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;span&#39;</span><span class="p">).</span><span class="nx">filter</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">text</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span> <span class="p">}).</span><span class="nx">remove</span><span class="p">();</span> </span></pre></div> </td></tr></table>
jquery
Copyrighted, illegal, or inappropriate content? Email [email protected].