<script>
$(document).ready(function(){
$("#nav li h3").hover(function() {
$(this)
.parent("li")
.find("p")
.css({
position:"absolute"
})
.removeClass("hidden")
.stop()
.animate({opacity: 1}, "fast");
}, function() {
$(this)
.parent()
.find("p")
.stop()
.animate({opacity: 0}, "fast");
});
</script>
and html
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<ul id="nav">
<li>
<table>
<tr>
<td><h3>name</h3></td>
</tr>
</table>
<p class="hidden">description</p>
</li>
</ul>
… and css style:
.hidden {
display: none;
}
when i hover name is result not show tooltip of
tag, how to fix ?
I found the following errors in your code:
}).parent("li")needs to be changed to.closest("li")in two places because.parent()only looks up one levelposition: absoluteis not needed if you want it to display in place where it is in the HTML.fadeIn()and.fadeOut()instead ofremoveClass()and.animate()..stop(), you want to also clear it from the queue with.stop(true).This code will work:
Working demo here: http://jsfiddle.net/jfriend00/3A4fv/
I realized this can be done much shorter like this:
Working demo of this one here: http://jsfiddle.net/jfriend00/QCEy6/