Note that there are some explanatory texts on larger screens.

plurals
  1. POHover effect with jQuery to affect container div
    text
    copied!<p>I have the following jQuery <strong>Demo</strong>: <a href="http://jsfiddle.net/FTERP/" rel="nofollow">http://jsfiddle.net/FTERP/</a></p> <p>Currently when I hover over the blue box, the <code>img</code> inside <code>steve</code> div fades out.</p> <p>Is it possible that <strong>when I hover over the blue box('<em>john</em>'), the whole red area ('<em>container</em>') opacity drops to 0.4</strong>, but the blue box remains 100% blue?</p> <p>Here is my <strong>HTML:</strong></p> <pre><code>&lt;div id="container"&gt; &lt;div id="john" class="character normalClassName1"&gt; &lt;a href="#" id="link1"&gt;&amp;nbsp;&lt;/a&gt; &lt;/div&gt; &lt;div id="steve" class="character"&gt; &lt;img src="http://placehold.it/400x400" /&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>Javascript:</strong></p> <pre><code> $(function() { $('#john').mouseenter(function() { $(this).addClass('hoverClassName1'); $('.character[id!=john]').css({opacity:0.5}); var button = $(this).find('.button'); button.html('View more'); }).mouseleave(function () { $('.hoverClassName1').removeClass('hoverClassName1'); $('.character').css({opacity:1}); $('.button').html('View'); }); }); </code></pre> <p><strong>CSS:</strong></p> <pre><code>#container {width:100%;background:red;float:left;height:450px} #john {position:relative;margin-top:-80px;margin-left:0px;background:blue;height:380px;float:left;width: 495px;} #john div {margin-left:250px;width:180px;height:float:left;margin-top:205px} #john div p {color:#074471;font-weight:bold;font-size:13px;margin-left:20px;} #steve img {float:left} #link1 {background:transparent;position:absolute;top:0px;left:0;width:100%;height:100%;z-index:1} .normalClassName1 {width:495px!important;z-index:3;} .hoverClassName1 {width:495px;z-index:4!important} </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