首页 > 应用开发 > > 请问各位大神关于div选中效果的事
下面是border的部分:
<div class="demo">
<div>中国</div>
<br/>
<div>俄国</div>
<br/>
<div>泰国</div>
</div>
下面是CSS部分:
.demo div{
text-align: center;
line-height: 40px;
font-weight: bold;
border:1px solid #BDCFE4;
border-radius: 300px;
margin: 0 auto;
width: 200px;
height: 40px;
border: 1px solid #003BB3;
}
下面是Jquery部分:
$(function(){
$(".demo div").mouseover(function(){
$(this).css("background-color","#149BDF");
$(this).css("cursor","pointer")
})//移入背景变淡蓝色
$(".demo div").mouseout(function(){
$(this).css("background-color","white");
})//移出恢复白色背景色
})
是这样的,我想让class=demo的div里面的3个子div(中国,俄国,泰国这三个div)点击后背景色跟移入的背景色一样,点击另一个div后背景色跟移入的背景色一样,但之前点击过的div背景色恢复成白色背景色
请问要怎么做?(里面的div不要去添加ID)来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1976/viewspace-3167933/ ,如需转载,请注明出处,否则将追究法律责任。