snipt

Ctrl+h for KB shortcuts

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/
https://snipt.net/raw/0dc3ee6be83acf2f279c8f0ff1d1ba57/
0dc3ee6be83acf2f279c8f0ff1d1ba57
js
JavaScript
7
2016-09-26T11:27:23
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 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

JavaScript

jQuery Click

1
2
3
4
5
6
7
function XLS_DL_ClickListener() {
    $("a#download_xls").click(function() {
        $("#m2_MB_btnSubmit2").trigger('click');

        return false;
    });
}
https://snipt.net/embed/d9f530e9a1b9c092b306c21d6998d260/
https://snipt.net/raw/d9f530e9a1b9c092b306c21d6998d260/
d9f530e9a1b9c092b306c21d6998d260
js
JavaScript
7
2016-09-21T10:24:02
True
False
False
Jan 19, 2013 at 10:20 AM
/api/public/snipt/54025/
jquery-click
<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 id="L-1"><a name="L-1"></a><span class="kd">function</span> <span class="nx">XLS_DL_ClickListener</span><span class="p">()</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="s2">&quot;a#download_xls&quot;</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-3"><a name="L-3"></a> <span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#m2_MB_btnSubmit2&quot;</span><span class="p">).</span><span class="nx">trigger</span><span class="p">(</span><span class="s1">&#39;click&#39;</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="k">return</span> <span class="kc">false</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>
button, click, jquery, trigger

JavaScript+PHP

onclick event listener on flash (swf)

1
2
3
4
// onclick event listener on flash (swf) in chrome
$('#layer1').mousedown(function() {
  alert('mouse down');
});
https://snipt.net/embed/0a17a726dce2cd34f9294304ed4195e8/
https://snipt.net/raw/0a17a726dce2cd34f9294304ed4195e8/
0a17a726dce2cd34f9294304ed4195e8
js+php
JavaScript+PHP
4
2016-09-26T03:07:02
True
False
False
/api/public/snipt/31551/
onclick-event-listener-on-flash-swf
<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 id="L-1"><a name="L-1"></a><span class="c1">// onclick event listener on flash (swf) in chrome</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#layer1&#39;</span><span class="p">).</span><span class="nx">mousedown</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;mouse down&#39;</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>
chrome, click, flash, jquery, onclick, swf
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.