私はこの進行状況バーを動作させています。私は、チェックボックスの多くがチェックされたときに色が変化しているとの問題を抱えています唯一の事...javascriptは即座に背景を変更します
0-3 background = red
4-7 = yellow
8-10 = Green
マイCSS
.progress-bar-wrapper .progress-bar-filling {
height: 100%;
color: #fff;
text-align: right;
width: 0;
background-color: #39b54a;
border-radius:20px;
}
.progress-bar-wrapper .progress-bar-percent {
font-weight: 400;
font-family: sans-serif;
color: #626162;
padding-top: 6px;
display: block;
}
私のHTML/Javascriptの
<div id="yyy">
<input type="checkbox" class="check_id" onclick="xxx()" checked>
<input type="checkbox" class="check_id" onclick="xxx()">
<input type="checkbox" class="check_id" onclick="xxx()">
<input type="checkbox" class="check_id" onclick="xxx()" checked>
<input type="checkbox" class="check_id" onclick="xxx()">
<input type="checkbox" class="check_id" onclick="xxx()" checked>
<input type="checkbox" class="check_id" onclick="xxx()">
<input type="checkbox" class="check_id" onclick="xxx()">
<input type="checkbox" class="check_id" onclick="xxx()" checked>
<input type="checkbox" class="check_id" onclick="xxx()">
<div>
<script>
window.onload = xxx;
function xxx()
{
var zzz = $(".check_id:checked").length;
document.getElementById("insert").innerHTML = zzz
$(document).ready(function(){
function progress(percent, $element) {
var progressBarWidth = percent * $element.width()/100;
$element.find('.progress-bar-filling').animate({ width: progressBarWidth }, 300)
jFiddleはこちらJfiddle ありがとう
、それはdocument.ready内 –
ああ他の回答をすべてのあなたのコードを配置するのが最善ですパンチに私を打ちますので、私は答えを投稿しませんが、あなたがそれをしたい場合、あなたのものに基づいて働くフィドル:) https://jsfiddle.net/zhLe0fk9/1/ –
関数xxxの中でdocument.ready()は必要ありません()この関数はonload()およびonclick()と呼ばれ、 – vadimk