views:

38

answers:

2

Anybody see what's wrong? Doesn't seem to do anything. If i replace

$(this, '.inner').stop(true, false).fadeIn(250);

with

$(.fadeInOnHover .inner').stop(true, false).fadeIn(250);

then all the .inner elements on the page will fade in (which isn't really what i want, as i have ~10 of them). I know it's possible to achieve what i want to do, but i don't know how in this case. Thanks in advance :)

<script type="text/javascript">
$(document).ready(function() {
 $('.fadeInOnHover .inner').css("display","none");

 $('.fadeInOnHover').hover(function() {
  $(this, '.inner').stop(true, false).fadeIn(250);
 }).mouseout(function() {
  $(this, '.inner').stop(true, true).fadeOut(100);
 });
});
</script>
+1  A: 

Are you trying to fade the element within this? Something like:

$(this).find('.inner').stop(true, false).fadeIn(250);

Update:

This function doesn't use hover properly:

 $('.fadeInOnHover').hover(function() {
  $(this, '.inner').stop(true, false).fadeIn(250);
 }).mouseout(function() {
  $(this, '.inner').stop(true, true).fadeOut(100);
 });

You need to setup handlers for mouseenter and mouseleave on the hover (as per the documentation). Something like:

$('.fadeInHover').hover(function(){
  $(this).find(".inner").stop(true, false).fadeIn(250);
}, function(){
  $(this).find(".inner").stop(true, true).fadeOut(100);
});
Mike Robinson
but shouldn't $(this, '.inner') do the same thing, since it's telling to search within the "this" context?
Tesserex
You've got it reversed - you're searching for this within the .inner context. Using .find is the same thing, and recommended as the better choice by Resig.
Mike Robinson
Thanks, but still no result. I'll post my HTML in a new comment below. :)
Nike
A: 
<div class="post-footer fadeInOnHover">
    <div class="inner">
        <a href="remove.php?replyid=20&userid=nike1">
            <img src="images/icons/remove.png" alt="X"/>
            Remove comment
        </a>
    </div>
</div>
Nike