I'm trying to change the css of .target
that is the sibling of the parent of .hover
. Can't seem to get this code to work - I'm not sure if I need $(this) at the beginning of my function, or $('.target')... I think it might be .target because that is what I'm changing the css of 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 also doesn't work):
$('.target').parent(this).sibling().css('display', 'inline');
And here is html
<div class="target" style="display: none;">
</div>
<div>
<span class="hover">Hover</span>
</div>
EDIT-----------------
It seems that it doesn't work when a span
is class="hover"
.
EDIT numero dos --------------------
It seems that I had my <span>
two parents deep and needed .parent().parent()
Thanks.