私はjQuery-SlotMachine、特にランダマイザを使用しています。jQueryスロットマシンのアクティブな要素のテキストコンテンツを表示
<div id="machine1">
<span class="option">
<span>Example A</span>
<span>Example B</span>
</span>
</div>
<div id="machine2">
<span class="option">
<span>Example C</span>
<span>Example D</span>
</span>
</div>
<div id="results">
<span></span>
</div>
ここ
である私のJS:ここに私のHTMLです
var machine1 = $("#machine1").slotMachine({
active : 0,
delay : 500
});
var machine2 = $("#machine2").slotMachine({
active : 1,
delay : 500,
direction: 'down'
});
function onComplete(active){
switch(this.element[0].id){
case 'machine1':
$("#machine1Result").text(this.active);
break;
case 'machine2':
$("#machine2Result").text(this.active);
break;
}
}
$("#randomizeButton").click(function(){
machine1.shuffle(5, onComplete);
setTimeout(function(){
machine2.shuffle(5, onComplete);
}, 500);
});
だから私は「結果」と呼ばれるコンテナに結果を吐き出すている何をしようとしています。私はthis.Aactiveが私に現在の要素のインデックス番号を与えることを知っていますが、私が表示したいのはテキスト値です。そこで、私は "Example B Example C"のように見せたいと思います。
var $ results = $( '。active')のようなものを使ってみました。 $( '#results')を使ってください。しかし、jQueryは私の強い訴訟ではありません。
ご提案いただきありがとうございます。私はこれで遊んでいます。それが動作するように見えることはできません。私は[codepen here](https://codepen.io/simonfoust/pen/LzVEEZ?editors=1010#0)を作った。 – simonfoust
私の編集ソリューションを参照してください。トリッキー。 – PerpetualStudent
私はあなたの借金に入っています。 :) – simonfoust