On Hover, Show element and stay active until mouseout

by ashleycam3ron

HTML

<ul id="extra-info">
    <li class="item1">Item 1 Extra Info</li>
</ul>
<ul id="dots">
    <li class="item1">Item 1</li>
</ul>

CSS

ul#extra-info {
    margin: 0;
    padding: 0;
    list-style: none;
}
ul#extra-info li {
    display: none;
    width: 100px;
    height: 50px;
    border: 1px solid red;
}
ul#dots {
    margin: 0;
    padding: 0;
    list-style: none;
}
ul#dots li {
    width: 60px;
    height: 30px;
    border: 1px solid green;
    position: absolute;
    top: 80px;
}
}

JavaScript

var location, timeout = 0;

$("#dots li").hover(

function () {
    location = $(this).attr("class");
    $("#extra-info ." + location).fadeIn("fast");
},

function () {
    timeout = setTimeout(function () {
        $("#extra-info ." + location).stop(true, false).fadeOut("fast");
    }, 500);
});

$('#extra-info li').mouseenter(function(){
   clearTimeout(timeout);   
}).mouseleave(function(){
   $(this).fadeOut('fast');
})