- 1 2 $(document).ready(function() {
- 3
- var machine1 = $("#machine1").slotMachine({
- 4 active: 0,
- 5 delay: 500 6
- });
- 7 8
- var machine2 = $("#machine2").slotMachine({
- 9 active: 1,
- 10 delay: 500 11
- });
- 12 13
- var machine3 = $("#machine3").slotMachine({
- 14 active: 2,
- 15 delay: 500 16
- });
- 17 18
- function onComplete($el, active) {
- 19
- switch ($el[0].id) {
- 20
- case'machine1':
- 21 $("#machine1Result").text("Index: " + active.index);
- 22
- break;
- 23
- case'machine2':
- 24 $("#machine2Result").text("Index: " + active.index);
- 25
- break;
- 26
- case'machine3':
- 27 $("#machine3Result").text("Index: " + active.index);
- 28
- break;
- 29
- }
- 30
- }
- 31 32 $("#slotMachineButton1").click(function() {
- 33 34 machine1.shuffle(3, onComplete);
- 35 36 setTimeout(function() {
- 37 machine2.shuffle(3, onComplete);
- 38
- },
- 500);
- 39 40 setTimeout(function() {
- 41 machine3.shuffle(3, onComplete);
- 42
- },
- 1000);
- 43 44
- }) 45
- });
- 46
来源: http://www.bubuko.com/infodetail-1989959.html