私は各質問がモーダルで表示されるテストを行いました。同じモーダルで、内部の内容のみが各質問の後に変更されます。結果は同じモーダルでも表示する必要があります。結果を表示するために、progressbar.js(http://kimmobrunfeldt.github.io/progressbar.js/#examples)を使用します。 (モーダルがまだ表示されていない場合)最後の質問は、私はブートストラップモーダルポップアップ(javascript、jquery)で関数を実行する方法
<h2 style='text-align: center; font-weight: bold;'>Your score is:</h3><br>
<div style='margin: auto;' class='progress1' value='0'></div>
にモーダルコンテンツを変更し、新しいクラスを追加して行われた後
function result() {
$('.progress1').css('display', 'block');
var startColor = '#FC5B3F';
var endColor = '#6FD57F';
var circle = new ProgressBar.Circle('.progress1', {
color: startColor,
easing: 'easeIn',
strokeWidth: 8,
trailWidth: 0,
duration: 2000,
text: {
value: '0',
style: {
color: '#000'
}
},
step: function(state, bar) {
bar.setText((bar.value() * 100).toFixed(0));
}
});
function rangeToPercent(number, min, max){
return ((number - min)/(max - min));
}
var value = rangeToPercent(counterAnswer, 0, counterQ)
// This will determine the circumference of the circle
circle.animate(value, {
from: {color: startColor},
to: {color: endColor},
step: function(state, circle, bar) {
circle.path.setAttribute('stroke', state.color);
console.log(circle);
circle.setText((circle.value() * 100).toFixed(0));
}
});
}
:これは私のインデックスファイルにどのように見えるかですモーダル $('#myModalTest').addClass('result');
。 私のスクリプトで私は持っています: $(".result").on('shown.bs.modal', function() { result(); });
しかし、これは動作しません。 result();
をsetTimeOut
に入れようとしましたが、$(".result").on('shown.bs.modal', function() {result();});
なしで実行しましたが、4回実行して4回の円を描いています(理由は分かりません)。 助けてください。
ありがとうございますが、動作しません( – Prolomzzz