0

I am trying to add opacity to a div which contains anchor tag,image, caption(span) .

On hovering of caption i want to show my caption only making all of div blur... So i had used not like this

$(this).not('.Caption').css('opacity', '0.4');

my body is like

<div>
    <a href="#"><img src=""/></a>
    <span class='Caption'>caption</span>     
</div>

See my fiddle for better understanding..FiDDle

UPDATE: Actually i am trying to implement like the last demo in Plugin , lastly i ended like the fiddle above

4
  • $(this).find(':not(.Caption)').css('opacity', '0.4'); Commented Jul 22, 2014 at 8:02
  • @Satpal - you're sure that was a valid edit? Perhaps the OP doesn't really have a class attribute for that span element... Commented Jul 22, 2014 at 8:03
  • 1
    @Lix, Yes that was valid edit, OP has provided fiddle. Its mentioned there. Commented Jul 22, 2014 at 8:04
  • @Satpal - ahh.. I didn't look at the fiddle... Carry on :) Commented Jul 22, 2014 at 8:05

4 Answers 4

1

you mean like this? => http://jsfiddle.net/ggLG8/6/

$('.thumbnail').hover(function() {
      $(this).children().not('.Caption').css('opacity', '0.4');
},function(){
    $(this).children().not('.Caption').css('opacity', '1');
});

also you have to remove the opacity:0.4; from the .thumbnail:hover in CSS

Sign up to request clarification or add additional context in comments.

6 Comments

This doesn't do anything.
@TimBJames check out the fiddle, the .Caption opacity is not changing, but the rest are!
@user3860465 okay, I did, but I don't see a "caption"
@user3860465 oh I got it, you mean you wanna make it look like this => jsfiddle.net/ggLG8/9
thanx..i really appreciate u..still i am confusing in jquery..certain options for only certain situations..:)
|
0

You can use:

$(this).find('*').not('.Caption').css('opacity', '0.4');

This would set the opacity to all the child elements except one with class Caption.

Comments

0

this happend because ".caption" element is inside of your "Div"
try this:

<div class="someclass">
<div class="thumbnail" >
<a class="fancybox" href="http://demo.phpgang.com/crop-images/demo_files/pool.jpg" rel="group1">
    <img width="150" height="120" src="http://demo.phpgang.com/crop-images/demo_files/pool.jpg"/>
</a>
    </div>
    <span class='Caption' contenteditable='true'>Caption</span>
</div>

Comments

0

The problem isn't your jQuery, but because you are applying opacity to an element that contains other elements. When you do this, all the elements within the containing element inherit the opacity.

The simplest solution would be to remove the opacity and just change the background color of the .thumbnail element, and remove the opacity from the css style.

$('.thumbnail').hover(function() {
      $(this).not('.Caption').css('background-color', 'rgba(249, 160, 160, 0.4)');
      $(this).find('.Caption').animate({
          opacity: 'show',
          bottom: 0
      }, 'fast');    
});

See this updated fiddle

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.