【问题标题】:JQuery li onhover show another liJQuery li on hover show another li
【发布时间】:2010-02-08 13:02:45
【问题描述】:
可能很简单的 JQuery 事情,但我想做这样的事情:
<ul>
<li>menu item1</li>
<li>menu item2</li>
</ul>
悬停显示来自另一个 UL LIlist 的图像,例如
<ul>
<li>image 1</li>
<li>Image 2</li>
</ul>
请有任何建议 -= 谢谢
【问题讨论】:
标签:
jquery
html-lists
mousehover
【解决方案1】:
你需要像This 这样的东西,但是稍微修改了一下:)
【解决方案2】:
您可以使用 index (1.4) 方法来确定悬停的 li。然后使图像可见。这只是一个开始,需要一些 CSS 等来使它看起来不错。
$("otherUl li").hide(); //hide all images to start
$("#myUL li").hover(function(){
i = $(this).index(); //gets the current index 0 based
$("#otherUL li:nth-child(i+1)").show();//gets the index of the image element 1 based
}
, function(){
$("#otherUL li").hide(); //hide all on mouse out
});