1
我有一個div。 在我的CSS中,我在這個div上添加':before'來創建其他顏色塊。Jquery:之前和Css
在jquery中,我想改變鼠標懸停的顏色,但只爲「div:before」塊,但它不起作用。
我該如何解決我的問題?
THKS
我的CSS:
div {
background:cyan;
width:200px;
height:300px;
}
div.color:before {
content:'Color me !';
background:orange;
width:100px;
height:100px;
display:inline-block;
position:absolute;
}
我的jQuery:
$('div').addClass('color');
$("div").toggleClass("color").mouseover(function() {
$(this).stop().css({ 'background':'#FF0000' });
});
$("div").toggleClass("color").mouseout(function() {
$(this).stop().css({ 'background':'#FFFF00' });
});
開始:HTTP://計算器.com/questions/5814810/target-before-and-after-pseudo-elements-with-jquery and follow to http://stackoverflow.com/questions/5041494/manipulating-css-pseudo-elements-using-jquery-eg -before-and-after,然後http://api.jquery.com/category/selectors/#Not_supported – MonkeyZeus