我有本期:我通过CSS定义当前角色的div
元素使用:之前通过jQuery
.divElement:before {
background-image: url(../images/triangle.png);
background-repeat: no-repeat;
content: "";
height: 20px;
left: 62%;
margin: 0 0 0 -50px;
position: absolute;
top: -20px;
width: 100px;
}
.divElement{
background: none repeat scroll 0 0 #FFF8D6;
border-radius: 10px 10px 10px 10px;
color: black;
font: 1em/1.4 Cambria,Georgia,sans-serif;
margin: 0px 500px 3em;
padding: 15px;
position: relative;
text-align: center;
}
我创造了这个元素动态使用jQuery:$('<div class="divElement"><p><strong></strong></p></div>').appendTo(....)
这正常工作。使用jQuery时,问题就变成了,我尝试动态改变backgroung-image
和divElement
之前的内容(这是我在CSS定义与:before
)
我想是这样的background-image
的top
属性,但不工作:
$('.divElement:before').css('background-image', 'url(../images/triangle_reverse.png)');
我该怎么做?谢谢大家!
thankssss..this work incorrectyyyyy !!!!! – user1645419
很酷,很高兴提供帮助;) –
请注意:伪类选择器在IE 8之前的IE版本中不起作用。 – Remo