I have an image that I want when I mouse over on it, an ul
must be shown and when I leave the ul
it must be close the ul
.
HTML:
<img id="ro" src="setting.png" onmouseover="rotate()" style="width:20px;height:20px;border:none;"/>
<br />
<ul id="settings" style="position:fixed;" onmouseout="hj()">
<li><a href="#">111</a></li>
<li><a href="#">222</a></li>
<li><a href="#">333</a></li>
<li><a href="#">444</a></li>
</ul>
When I over mouse on the picture,the picture rotate 360 degrees and then show the ul
.
JS:
function show(n) {
var tds = $("#settings li") ;
setTimeout(function(){ tds.eq(n).fadeIn(500); }, n*100);
}
And when I out mouse from the ul
run this code:
function hj() {
var tds = $("#settings li");
for (var i = tds.length - 1; i > -1; i--) {
hide(i) ;
}
}
And if I again hover mouse on the picture the picture rotate again and close the ul
with this code:
function hide(n) {
var tds = $("#settings li");
setTimeout(function() { tds.eq(tds.length - n - 1).fadeOut(500); }, n*100);
}
But when the ul
opened, when I go on the 3rd or 4th element(3rd or 4th li
) the ul
closed.
where is it wrong?