使用removeClass和addClass我想,一旦它被点击,突出一个按钮和一个特定的类添加到<div>
有class
item
为好。如何通过点击按钮
HTML
<button type="button" class="btn gridLarge">largegrid</button>
<button type="button" class="btn grid active">smallgrid</button>
<button type="button" class="btn list">list</button>
<div class="item">text</div>
CSS
.item{
height:240px;
border:1px solid orange;
}
.item.list{
width:600px;
height:500px;
border:1px solid red;
}
.item.gird{
width:400px;
height:500px;
border:1px solid red;
}
.item.gridlarge{
width:500px;
height:500px;
border:1px solid red;
}
button{
cursor:pointer;
border:1px solid green;
padding:20px;
color:red;
margin-bottom:20px;
}
.btn.active{
color:green;
background-color:red;
}
例如
- 当点击
button.gridLarge
,我想highlig HT它(通过添加类active
)和类.gridLarge
添加到div.item
- 当点击
button.grid
,我想强调它和类.grid
添加到div.item
- 当点击
button.list
,我想强调它和类.list
添加到div.item
下面的代码我到目前为止:JSFiddle
__I不应该回答了.__但这里的东西给你与http://jsfiddle.net/satpalsingh/XG6Jn/ – Satpal
是的,先生玩..但我也(.item)是addClass格,列表,大网格.. – JavaEagle
你明白。我的意思是(.item)是Css类。 – JavaEagle