0
要素の幅を:afterで動的に変更しようとしています。しかし、それは反映されていません。助けてもらえますか?ここで JQueryからの擬似CSS要素の後ろの幅を変更します。
$(function(){
var a=20;
$(".progress:after").width(a+"%");
// This is not showing 20%. Still shows 50% which was coded in CSS
});
.progress {
width:200px;
height:50px;
border:1px solid black;
position:relative;
}
.progress:after {
content:'\A';
position:absolute;
background:black;
top:0; bottom:0;
left:0;
width:50%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="progress"></div>
あなたは '$( "進歩。:後")を使用することはできません'セレクタとして。 – Twisty
質問..偽の目的は何ですか?動的なコンテンツがありますか? – Cam
見てくださいhttps://stackoverflow.com/questions/29260296/modify-pseudo-select-after-in-javascript – HTCom