<div id="box"></div>
<div class="text"></div>?
$(document).ready(function() {
$('#box').click(function() {
$('.text').slideToggle('slow');
});
});
#box{
height:40px;
width:100px;
background:red;
}
#box:hover{background:blue;}
#box:after{
content: "";
height: 10px;
position: absolute;
width: 0;
margin-top:40px;
margin-left:40px;
border: 10px solid transparent;
border-top-color: red;
}
#box:hover:after{
border-top-color: blue;
}
.text{
display:none;
height:40px;
width:100px;
background:#fd0;
margin-top:20px;
}
http://jsfiddle.net/zfQvD/16/jQuery的addClass後/前
這是可能使用jQuery添加樣式after
箭頭? 當text class
已關閉,刪除after
箭頭類 如果顯示text class
,那麼添加箭頭? 我試過了,但似乎不起作用
你能改寫你要完成的任務在點擊框添加一行到您的JS這個類?你的措詞有點遺失 – AJak
你不能在JavaScript中設計僞元素,因爲它們實際上不存在於DOM中。使用一個普通的標籤,而不是.. – elclanrs
只需添加樣式箭頭時/展開/,刪除箭頭時不/擴大/ – olo