jquery - $(this) child element css change not working at all -
i have little question.
$('.item').mouseenter(function() { settimeout(function() { $(this).find('.item-overlay').css('z-index', '-1'); }, 300); }).mouseleave(function() { $(this).find('.item-overlay').css('z-index', ''); }); <div class="item"> <div class="item-overlay"> </div> <iframe>...</iframe> </div>
everything works fine, except 1 small thing. z-index isn't changing. can guys me out this? i've tried "next", "child", "find" - none worked :(
this
within function you're passing settimeout
window
, not element. (this
depends on how function called, not it's used.)
you can save this
value event handler got (or actually, you're going jquery-wrap it, var
outside settimeout
function), e.g.:
$('.item').mouseenter(function() { var $this = $(this); settimeout(function() { $this.find('.item-overlay').css('z-index', '-1'); }, 300); // ...
Comments
Post a Comment