data-atributeを使用して進行状況バーを作成しようとしていますが、Jqueryでは両方のアクションを同時に実行できません。両方のアクションを同時に実行することはできません
<div class="progressbar">
<div class="progressvalue" data-percent="50"></div>
</div>
.progressbar {
background: #9696A0;
height: 20px;
border-radius: 10px;
color: #fff;
text-align: center;
font-size: 14px;
position: relative;
z-index: 3;
}
.progressvalue {
background: #4650C8;
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 0;
z-index: -1;
border-radius: 10px;
}
$('.progressvalue').each(function() {
var $this = $(this);
$this.css('width', $this.data('percent') + '%');
$this.parent().text('tournament progress: ' + $this.data('percent') + '%');
});
結果は次のとおりです。次の2つの問題を持っている
問題は何ですか? https://jsfiddle.net/usyL2vcw/ – Mohammad
を参照してください.Jqueryの2番目の前に "$"が欠けていたのを見ましたが、問題はテキストのみが表示されることです...テキストと進捗状況の背景が表示される必要があります。 – Liimd
テキストを設定した後でDOMを調べると、色の付いた要素が削除されているように見えます。 – Douglas