snipt

Ctrl+h for KB shortcuts

Jade

Iterate 2 values with each in Jade

1
2
3
4
values = {"Word 1": "Apple", "Word 2": "IBM"};
ul
	each val, key in values
		li #{key}: #{val}
https://snipt.net/embed/9463f5a46b0f027472c2757bd333c770/
/raw/9463f5a46b0f027472c2757bd333c770/
9463f5a46b0f027472c2757bd333c770
jade
Jade
4
2016-12-31T16:16:55
True
False
True
Nov 17, 2013 at 04:04 AM
/api/public/snipt/94638/
iterate-2-values-in-jade
<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">values</span> = {&quot;Word 1&quot;: &quot;Apple&quot;, &quot;Word 2&quot;: &quot;IBM&quot;}; </span><span id="L-2"><a name="L-2"></a><span class="nt">ul</span> </span><span id="L-3"><a name="L-3"></a> <span class="nt">each</span> val, key in values </span><span id="L-4"><a name="L-4"></a> <span class="nt">li</span> <span class="si">#{</span><span class="n">key</span><span class="si">}</span>: <span class="si">#{</span><span class="k">val</span><span class="si">}</span> </span></pre></div> </td></tr></table>
each, jade

Jade

Iterate 1 value with each in Jade

1
2
3
4
5
ul
	items = ["Главная", "О нас", "Галерея", "Схема проезда", "Выезд", "Контакты"]
	each item, i in items
		li 
			a(href='#page-section#{i+1}') #{item}
https://snipt.net/embed/c17e62504b4a5f10495a882620138949/
/raw/c17e62504b4a5f10495a882620138949/
c17e62504b4a5f10495a882620138949
jade
Jade
5
2016-12-14T12:44:41
True
False
True
Nov 17, 2013 at 03:57 AM
/api/public/snipt/94637/
iterate-values-in-jade
<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="nt">ul</span> </span><span id="L-2"><a name="L-2"></a> <span class="nt">items</span> = [&quot;Главная&quot;, &quot;О нас&quot;, &quot;Галерея&quot;, &quot;Схема проезда&quot;, &quot;Выезд&quot;, &quot;Контакты&quot;] </span><span id="L-3"><a name="L-3"></a> <span class="nt">each</span> item, i in items </span><span id="L-4"><a name="L-4"></a> <span class="nt">li</span> </span><span id="L-5"><a name="L-5"></a> <span class="nt">a</span>(<span class="na">href=</span><span class="s">&#39;#page-section#{i+1}&#39;</span>) <span class="si">#{</span><span class="n">item</span><span class="si">}</span> </span></pre></div> </td></tr></table>
each, jade

JavaScript

Foldable text with headings (jQuery)

1
2
3
4
5
6
var $posttext = $('.post-text');
$posttext.find('h1').nextUntil('h1').hide();
$posttext.find('h1:first').nextUntil('h1').show();
$posttext.find('h1').on('click', function() { 
	$(this).nextUntil('h1').slideToggle(400);
});
https://snipt.net/embed/a0b9c109d617a9a49120c5744c25e1a6/
/raw/a0b9c109d617a9a49120c5744c25e1a6/
a0b9c109d617a9a49120c5744c25e1a6
js
JavaScript
6
2016-12-21T03:41:24
True
False
True
Aug 06, 2013 at 08:08 PM
/api/public/snipt/72403/
foldable-text-with-headings-jquery
<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="kd">var</span> <span class="nx">$posttext</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.post-text&#39;</span><span class="p">);</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">$posttext</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="s1">&#39;h1&#39;</span><span class="p">).</span><span class="nx">nextUntil</span><span class="p">(</span><span class="s1">&#39;h1&#39;</span><span class="p">).</span><span class="nx">hide</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a><span class="nx">$posttext</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="s1">&#39;h1:first&#39;</span><span class="p">).</span><span class="nx">nextUntil</span><span class="p">(</span><span class="s1">&#39;h1&#39;</span><span class="p">).</span><span class="nx">show</span><span class="p">();</span> </span><span id="L-4"><a name="L-4"></a><span class="nx">$posttext</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="s1">&#39;h1&#39;</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="p">{</span> </span><span id="L-5"><a name="L-5"></a> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">nextUntil</span><span class="p">(</span><span class="s1">&#39;h1&#39;</span><span class="p">).</span><span class="nx">slideToggle</span><span class="p">(</span><span class="mi">400</span><span class="p">);</span> </span><span id="L-6"><a name="L-6"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
javascript, jquery