Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Hover event is not bound to the child element
    text
    copied!<p>I bind the hover event to the <code>li</code> tag(see my code below or fiddle, for code details), i.e. when i hover over the <code>li</code>, i added the class which changes the background of the <code>li</code>.</p> <p><code>li</code> tag is having one <code>a</code> tag which encloses two <code>span</code> tags with texts, when i hover over the two text <code>span</code> tags, i am not seeing the hover event is executed. Please see my fiddle <a href="http://jsfiddle.net/shmdhussain/JbVMv/" rel="nofollow">http://jsfiddle.net/shmdhussain/JbVMv/</a> . Thanks in advance for any help.</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head&gt; &lt;title&gt;Untitled Page&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="css/reset.css"&gt;&lt;/link&gt; &lt;link rel="stylesheet" type="text/css" href="css/mystyle.css"&gt;&lt;/link&gt; &lt;script src="/jquery-my.js" &gt;&lt;/script&gt; &lt;script&gt; jQuery(function($){ var groupTab = $("ul").children("li"); groupTab.hover(function(){ if(!($(this).children("a").hasClass("current"))) { $(this).siblings("li").children("a").removeClass("hoverBG"); $(this).children("a").addClass("hoverBG"); } }); groupTab.mouseout(function(){ $(this).children("a").removeClass("hoverBG"); }); }); &lt;/script&gt; &lt;style&gt; li{background-color:#DCDEDB; border:1px solid black; padding:20px; } .hoverBG{ background-color:red; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=""&gt; &lt;ul class="" id=""&gt; &lt;li class=" "&gt; &lt;a class="current" href="#" &gt; &lt;span class=""&gt; MyName &lt;/span&gt; &lt;br&gt; &lt;span class=""&gt;MyData&lt;/span&gt; &lt;/a&gt; &lt;/li&gt; &lt;li class="" &gt; &lt;a class="" href="#" &gt; &lt;span class=""&gt; MyName &lt;/span&gt; &lt;br&gt; &lt;span class=""&gt;MyData&lt;/span&gt; &lt;/a&gt; &lt;/li&gt; &lt;li class="" &gt; &lt;a class="" href="#"&gt; &lt;span class=""&gt; MyName &lt;/span&gt; &lt;br&gt; &lt;span class=""&gt;MyData&lt;/span&gt; &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&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