snipt

Ctrl+h for KB shortcuts

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

Text only

Test

<a href="#">Test</a>
https://snipt.net/embed/43ba78c1fd0f4080a4e375dadd34a15d/
/raw/43ba78c1fd0f4080a4e375dadd34a15d/
43ba78c1fd0f4080a4e375dadd34a15d
text
Text only
1
2019-06-18T18:12:14
True
False
False
Mar 01, 2014 at 12:37 AM
/api/public/snipt/117787/
test-395
<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>&lt;a href=&quot;#&quot;&gt;Test&lt;/a&gt; </span></pre></div> </td></tr></table>
href

PHP

Generazione di un href

1
2
3
4
5
6
 <?
    $node_path = "node/<NID_HERE>";
    $link_href = url($node_path);
 ?>
    
<a class="preventivo" href="<?print $link_href?>"><strong>Richiedi</strong> un preventivo</a>
https://snipt.net/embed/899673c5ba1408ae48339b9a2d7c80a9/
/raw/899673c5ba1408ae48339b9a2d7c80a9/
899673c5ba1408ae48339b9a2d7c80a9
php
PHP
6
2019-06-12T21:49:18
True
False
False
/api/public/snipt/31418/
generazione-di-un-href
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x"> </span><span class="cp">&lt;?</span> </span><span id="L-2"><a name="L-2"></a> <span class="nv">$node_path</span> <span class="o">=</span> <span class="s2">&quot;node/&lt;NID_HERE&gt;&quot;</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a> <span class="nv">$link_href</span> <span class="o">=</span> <span class="nx">url</span><span class="p">(</span><span class="nv">$node_path</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> <span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-5"><a name="L-5"></a><span class="x"> </span> </span><span id="L-6"><a name="L-6"></a><span class="x">&lt;a class=&quot;preventivo&quot; href=&quot;</span><span class="cp">&lt;?</span><span class="k">print</span> <span class="nv">$link_href</span><span class="cp">?&gt;</span><span class="x">&quot;&gt;&lt;strong&gt;Richiedi&lt;/strong&gt; un preventivo&lt;/a&gt;</span> </span></pre></div> </td></tr></table>
a, href, link