snipt

Ctrl+h for KB shortcuts

JavaScript

Detect animation end jQuery/CSS

1
2
3
4
5
el.one('webkitAnimationEnd oanimationend msAnimationEnd animationend',   
function(e) {
    // code to execute after animation ends    
    myBox.removeClass('change-size');
});
https://snipt.net/embed/b71bacffabc246414df93af4df6860dc/
/raw/b71bacffabc246414df93af4df6860dc/
b71bacffabc246414df93af4df6860dc
js
JavaScript
5
2019-06-20T12:38:56
True
False
False
/api/public/snipt/114964/
detect-animation-end-jquerycss
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nx">el</span><span class="p">.</span><span class="nx">one</span><span class="p">(</span><span class="s1">&#39;webkitAnimationEnd oanimationend msAnimationEnd animationend&#39;</span><span class="p">,</span> </span><span id="L-2"><a name="L-2"></a><span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="c1">// code to execute after animation ends </span> </span><span id="L-4"><a name="L-4"></a> <span class="nx">myBox</span><span class="p">.</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;change-size&#39;</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
css, jquery, js

JavaScript

WebP Image with Fallback

<img src="image.webp" onerror="this.onerror=null; this.src='image.png'">
https://snipt.net/embed/3129a92b49c67565ace361fb10dedc62/
/raw/3129a92b49c67565ace361fb10dedc62/
3129a92b49c67565ace361fb10dedc62
js
JavaScript
1
2019-06-24T06:02:12
True
False
False
Apr 08, 2014 at 09:22 AM
/api/public/snipt/114585/
webp-image-with-fallback
<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="o">&lt;</span><span class="nx">img</span> <span class="nx">src</span><span class="o">=</span><span class="s2">&quot;image.webp&quot;</span> <span class="nx">onerror</span><span class="o">=</span><span class="s2">&quot;this.onerror=null; this.src=&#39;image.png&#39;&quot;</span><span class="o">&gt;</span> </span></pre></div> </td></tr></table>
image, img, js, webp

JavaScript

Get ID in js w/jQuery dom object return

$( document.getElementById("some_id") );
https://snipt.net/embed/a263aa5f5037f8d42f5005eb040cd348/
/raw/a263aa5f5037f8d42f5005eb040cd348/
a263aa5f5037f8d42f5005eb040cd348
js
JavaScript
1
2019-06-24T20:01:43
True
False
False
Apr 08, 2014 at 09:22 AM
/api/public/snipt/107720/
get-id-in-js-wjquery-dom-object-return
<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">$</span><span class="p">(</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">&quot;some_id&quot;</span><span class="p">)</span> <span class="p">);</span> </span></pre></div> </td></tr></table>
element, get, id, jquery, js