Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>&lt;html&gt; &lt;head&gt; &lt;style&gt; .box { opacity:1; color: white; width: 100px; height: 100px; } #box1 { background-color: green; } #box2 { background-color: red; } #box3 { background-color: blue; } div.fadeAway1 { opacity:0; -webkit-transition-property: opacity; -webkit-transition-duration: 2s; } div.fadeAway2 { opacity:0; -webkit-transition-property: opacity; -webkit-transition-duration: 5s; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="box1" class="box"&gt;&lt;/div&gt; &lt;div id="box2" class="box"&gt;&lt;/div&gt; &lt;div id="box3" class="box"&gt;Tap to fade&lt;/div&gt; &lt;script&gt; (function () { document.getElementById('box3').addEventListener('click', function() { for ( var i = 1, stop = 2; i &lt;= stop; i += 1) { document.getElementById('box' + i).className = "box fadeAway" + i; } }, false); })(); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here's an example implementing jQuery:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style&gt; .box { opacity:1; color: white; width: 100px; height: 100px; } #box1 { background-color: green; } #box2 { background-color: red; } #box3 { background-color: blue; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="box1" class="box"&gt;&lt;/div&gt; &lt;div id="box2" class="box"&gt;&lt;/div&gt; &lt;div id="box3" class="box"&gt;Tap to fade&lt;/div&gt; &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready( function () { $("#box3").click(function() { for ( var i = 1, stop = 2; i &lt;= stop; i += 1) { $('#box' + i).fadeTo(500 * (i*2),0); } }); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload