snipt

Ctrl+h for KB shortcuts

JavaScript

jQuery Wildcard

1
2
3
4
5
$("[id$='txtcomPagerAlpha']")  //ENDS With

$("[id^='txtcomPagerAlpha']")  //STARTS With

$("[id*='txtcomPagerAlpha']") //CONTAINS
https://snipt.net/embed/51370e6b1fc4743a2125c867dab25864/
/raw/51370e6b1fc4743a2125c867dab25864/
51370e6b1fc4743a2125c867dab25864
js
JavaScript
5
2019-06-16T09:35:32
True
False
False
Apr 01, 2014 at 11:40 AM
/api/public/snipt/126495/
jquery-wildcard
<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">$</span><span class="p">(</span><span class="s2">&quot;[id$=&#39;txtcomPagerAlpha&#39;]&quot;</span><span class="p">)</span> <span class="c1">//ENDS With</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="nx">$</span><span class="p">(</span><span class="s2">&quot;[id^=&#39;txtcomPagerAlpha&#39;]&quot;</span><span class="p">)</span> <span class="c1">//STARTS With</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="nx">$</span><span class="p">(</span><span class="s2">&quot;[id*=&#39;txtcomPagerAlpha&#39;]&quot;</span><span class="p">)</span> <span class="c1">//CONTAINS</span> </span></pre></div> </td></tr></table>
jquery, wildcard

JavaScript

Jquery read web.config AppSettings

var settings = '<%=System.Configuration.ConfigurationManager.AppSettings["KEY"]%>'
https://snipt.net/embed/9fcc2c9c8d902acb9c7c620e573f284f/
/raw/9fcc2c9c8d902acb9c7c620e573f284f/
9fcc2c9c8d902acb9c7c620e573f284f
js
JavaScript
1
2019-06-15T16:37:48
True
False
False
Mar 26, 2014 at 01:19 PM
/api/public/snipt/125027/
jquery-leer-webconfig-appsettings
<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="kd">var</span> <span class="nx">settings</span> <span class="o">=</span> <span class="s1">&#39;&lt;%=System.Configuration.ConfigurationManager.AppSettings[&quot;KEY&quot;]%&gt;&#39;</span> </span></pre></div> </td></tr></table>
"read appsettings", jquery, web.cong

JavaScript

Fancybox open from needed index

$.fancybox.open($('.fancybox'), {index: 0});
https://snipt.net/embed/4d744b9fa5a28fda34ebe36ec7df5f47/
/raw/4d744b9fa5a28fda34ebe36ec7df5f47/
4d744b9fa5a28fda34ebe36ec7df5f47
js
JavaScript
1
2019-06-13T07:57:04
True
False
False
Mar 22, 2014 at 07:02 AM
/api/public/snipt/123027/
fancybox-open-from-needed-index
<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="nx">fancybox</span><span class="p">.</span><span class="nx">open</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.fancybox&#39;</span><span class="p">),</span> <span class="p">{</span><span class="nx">index</span><span class="o">:</span> <span class="mi">0</span><span class="p">});</span> </span></pre></div> </td></tr></table>
box, fancy, fancybox, gallery, image, images, jquery, modal, plugin

JavaScript

Test if href points image

1
2
3
4
if($(this).attr('href').indexOf('.jpg') > 0) // or any other extension
{
    //do what you want
}
https://snipt.net/embed/6b6e76de0f8d48d7e980f025b5f0f153/
/raw/6b6e76de0f8d48d7e980f025b5f0f153/
6b6e76de0f8d48d7e980f025b5f0f153
js
JavaScript
4
2019-06-17T04:36:27
True
False
False
Mar 17, 2014 at 01:11 PM
/api/public/snipt/122560/
test-if-href-points-image
<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="k">if</span><span class="p">(</span><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;href&#39;</span><span class="p">).</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;.jpg&#39;</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="c1">// or any other extension</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="c1">//do what you want</span> </span><span id="L-4"><a name="L-4"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
check, href, image, img, javascript, jpeg, jpg, jquery, js, test

JavaScript

Hide block on click outside of them

1
2
3
4
5
6
7
$(document).on('click', function(e) {
	var $container = $("#block");

	if (!$container.is(e.target) && $container.has(e.target).length === 0) {
		$container.hide();
	}
});
https://snipt.net/embed/0dc3ee6be83acf2f279c8f0ff1d1ba57/
/raw/0dc3ee6be83acf2f279c8f0ff1d1ba57/
0dc3ee6be83acf2f279c8f0ff1d1ba57
js
JavaScript
7
2019-06-15T21:26:04
True
False
False
/api/public/snipt/120311/
hide-block-on-click-outside-of-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> <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="nb">document</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <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-2"><a name="L-2"></a> <span class="kd">var</span> <span class="nx">$container</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#block&quot;</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">$container</span><span class="p">.</span><span class="nx">is</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">target</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="nx">$container</span><span class="p">.</span><span class="nx">has</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">target</span><span class="p">).</span><span class="nx">length</span> <span class="o">===</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-5"><a name="L-5"></a> <span class="nx">$container</span><span class="p">.</span><span class="nx">hide</span><span class="p">();</span> </span><span id="L-6"><a name="L-6"></a> <span class="p">}</span> </span><span id="L-7"><a name="L-7"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
click, hide, jquery, simple, snipet