Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>$(document).ready(function() { $('li.active').hover( function() { $('a', this).addClass('icon-white'); }, function() { $('a', this).removeClass('icon-white'); }); }); </code></pre> <p><strong><a href="http://jsfiddle.net/thecodeparadox/qzKzd/1/" rel="nofollow">DEMO 1</a></strong></p> <p>Also can write (Its better)</p> <pre><code>$('li.active').hover( function() { $('a', this).toggleClass('icon-white'); }); </code></pre> <p><strong><a href="http://jsfiddle.net/thecodeparadox/QStkd/96/" rel="nofollow">DEMO 2</a></strong></p> <p>Using jQuery <strong><a href="http://api.jquery.com/on" rel="nofollow"><code>.on()</code></a></strong> hover:</p> <pre><code>$(document).ready(function() { $('li.active').on('hover', function() { $('a', this).toggleClass('icon-white'); }); }); </code></pre> <p><strong><a href="http://jsfiddle.net/thecodeparadox/qzKzd/1/" rel="nofollow">DEMO 3</a></strong></p> <p><strong>According to comment</strong></p> <h3>How do I add class to <code>i</code>?</h3> <pre><code>$('i', this).addClass('icon-white'); </code></pre> <p>ans similarly for <code>.removeClass()</code> or <code>.toggleClass()</code>.</p> <p><strong>According to edit</strong></p> <pre><code>$(document).ready(function(){ $("li.active &gt; a &gt; i").addClass('icon-white'); }); </code></pre> <p><strong><a href="http://jsfiddle.net/thecodeparadox/3f3kr/2/" rel="nofollow">DEMO 4</a></strong></p> <p><strong>Combining with hover:</strong></p> <pre><code>$("li.active &gt; a &gt; i").addClass('icon-white'); $('li.active').hover( function() { $('a', this).toggleClass('icon-white'); }); </code></pre> <p><strong><a href="http://jsfiddle.net/thecodeparadox/3f3kr/5/" rel="nofollow">DEMO 5</a></strong></p>
 

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