I am trying to change the css .target , which is the parent of the .hover . This code doesn't seem to work - I'm not sure if I need $ (this) at the beginning of my function, or $ ('. Target') ... I think it could be .target, because thatβs what that I am changing css with .css() .
<script type="text/javascript"> $(document).ready(function() { $('.hover').hover( function(){ $(this).parent().siblings('.target').css('display', 'inline'); }, function(){ $(this).parent().siblings('.target').css('display', 'none'); } ); }); </script>
And here is my hunch (which doesn't work either):
$('.target').parent(this).sibling().css('display', 'inline');
And here is the html
<div class="target" style="display: none;"> </div> <div> <span class="hover">Hover</span> </div>
EDIT ----------------- It does not seem to work if span class="hover" .
EDIT num dos dos -------------------- It seems that I had <span> two parents deeply and needed .parent().parent() Thanks.
source share