简体   繁体   English

我如何通过悬停在此ul块之外的另一个li元素来更改li元素的css属性

[英]How I can change css property of a li element by hovering another li element which is outside of this ul block

I am creating two separate ul>li block to create a menu as like the below structure 我正在创建两个单独的ul> li块来创建菜单,如下所示

http://puu.sh/g0Khj/5fb3e53fa1.png http://puu.sh/g0Khj/5fb3e53fa1.png

I need to show some reflection of the hovered/selected menu, so I have decided to used two ul structure with same size. 我需要显示鼠标悬停/选定菜单的一些反射,因此我决定使用两个具有相同大小的ul结构。 Now my question is, if I hovered any li on the ul class a, I need to change the respected css(nth element) of the bottom ul, ie class b 现在我的问题是,如果我在ul类a上悬停了任何li,我需要更改底部ul所尊敬的css(nth元素),即b类

Is it possible? 可能吗?

Thanks 谢谢

You can use jquery 你可以使用jQuery

$(".a").children('li').each(function(indice, elt) {
     $(elt).hover(function(){
         var child = $(".b").children('li')[indice];
         $(child).css("your css");
     }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM