在另一个div上悬停时更改Div属性? [英] Change Div Property when hovering on another div?

查看:166
本文介绍了在另一个div上悬停时更改Div属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以基本上这就是我所要做的:

 < div id =1> 
< div id =top>< / div>
文本
文本
文本


< div id =bottom>< / div>
< / div>

我会如何去做以下事情:
如果有人悬停在div1 (整个容器div)改变底部div的属性(只有底部div),比如添加一个名为over的类。



我是确定有一种方法,但我猜它需要使用诸如jQuery的东西。

它很简单(这对我有用):

  $('#1')。hover(function(){
$('#bottom')。addClass('over');
})


So basically this is what I'm going to have:

<div id="1">
<div id="top"></div>
Text
Text
Text 
etc.

<div id="bottom"></div>
</div>

How would I go about doing the following: If someone hovers over div "1" (the entire container div) change the property of the "bottom" div (and only that bottom div) such as adding a class called "over".

I'm sure there's a way however I'm guessing it would need to use something such as jquery.

解决方案

If you have jquery, then it is pretty simple (this worked for me):

$('#1').hover( function() {
    $('#bottom').addClass('over');
})

这篇关于在另一个div上悬停时更改Div属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆