Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

JavaScript

Fix broken images automatically

1
2
3
$('img').error(function(){
	$(this).attr('src', 'img/broken.png');
});
https://snipt.net/embed/11b46d468543c142594c407058013be4/
https://snipt.net/raw/11b46d468543c142594c407058013be4/
11b46d468543c142594c407058013be4
js
JavaScript
3
2016-12-05T14:13:54
True
False
False
/api/public/snipt/109800/
fix-broken-images-automatically
<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></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;img&#39;</span><span class="p">).</span><span class="nx">error</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;src&#39;</span><span class="p">,</span> <span class="s1">&#39;img/broken.png&#39;</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
broken, fix, image, img, jquery, placeholder

CSS

clear placeholder

1
2
3
4
input:focus::-webkit-input-placeholder
{
	color: transparent;
}
https://snipt.net/embed/620afb440037610f4b9ee71f999a5913/
https://snipt.net/raw/620afb440037610f4b9ee71f999a5913/
620afb440037610f4b9ee71f999a5913
css
CSS
4
2016-12-04T22:40:47
True
False
False
May 06, 2013 at 12:22 PM
/api/public/snipt/60785/
clear-placeholder
<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="nt">input</span><span class="nd">:focus</span><span class="o">:</span><span class="nd">:-webkit-input-placeholder</span> </span><span id="L-2"><a name="L-2"></a><span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="nb">color</span><span class="o">:</span> <span class="nb">transparent</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
clear, css, placeholder

JavaScript

js placeholder

onblur="if(this.value=='') this.value='Keyword';" onfocus="if(this.value=='Keyword') this.value='';"
https://snipt.net/embed/9460734617e8506902f4e1502b5a765d/
https://snipt.net/raw/9460734617e8506902f4e1502b5a765d/
9460734617e8506902f4e1502b5a765d
js
JavaScript
1
2016-11-29T13:36:13
True
False
False
/api/public/snipt/33542/
js-placeholder
<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">onblur</span><span class="o">=</span><span class="s2">&quot;if(this.value==&#39;&#39;) this.value=&#39;Keyword&#39;;&quot;</span> <span class="nx">onfocus</span><span class="o">=</span><span class="s2">&quot;if(this.value==&#39;Keyword&#39;) this.value=&#39;&#39;;&quot;</span> </span></pre></div> </td></tr></table>
form, js, placeholder
Copyrighted, illegal, or inappropriate content? Email [email protected].