使用JavaScript

时间:2016-09-16 08:07:50

标签: javascript jquery css

我正在下注页面,其中短语不断更改数字。例如,

$6 231 515.23','6 431 515.23','6 831 515.23

然而,编码似乎对我不起作用,因为我对StackOverflow或其他论坛进行了一些研究,请提出建议。



var first = ['$6 231 515.23', '6 431 515.23', '6 831 515.23'];
var second = ['$6 231 515.23', '6 431 515.23', '6 831 515.23'];
var third = ['$6 231 515.23', '6 431 515.23', '6 831 515.23']
var i = 0;
var j = 0;
var k = 0;
var maxfirst = first.length - 1;
var maxsecond = second.length - 1;
var maxthird = third.length - 1;

function delay() {
  $('#intro').velocity("transi1ion.slideUpIn", 1250);
  setInterval(firstwordchange, 10);
  setInterval(secondwordchange, 500);
  setInterval(thirdwordchange, 500)
}

function firstwordchange() {
  if (i < maxfirst) i++;
  else i = 0;

  $('#firstword').velocity("transition.slideUpOut", 300);

  setTimeout(function() {
    $('#firstword').text(first[i]);
  }, 200);

  $('#firstword').velocity("transition.slideUpIn", 300);
}

function secondwordchange() {
  if (j < maxsecond) j++;
  else j = 0;

  $('#secondword').velocity("transition.slideUpOut", 300);

  setTimeout(function() {
    $('#secondword').text(second[j]);
  }, 200);

  $('#secondword').velocity("transition.slideUpIn", 300);
}

function thirdwordchange() {
  if (j < maxsecond) j++;
  else j = 0;

  $('#thirdword').velocity("transition.slideUpOut", 300);

  setTimeout(function() {
    $('#thirdword').text(second[j]);
  }, 200);

  $('#thirdword').velocity("transition.slideUpIn", 300);
}

setTimeout(delay, 700);
&#13;
.Jacpots_2 {
  left: 110px;
  top: 648px;
  position: absolute;
  font: 14px/43px"Microsoft YaHei";
}
.introchange2 {
  left: 110px;
  top: 675px;
  position: absolute;
  font: 14px/43px"Microsoft YaHei";
}
.Jacpots_3 {
  left: 110px;
  top: 755px;
  position: absolute;
  font: 14px/43px"Microsoft YaHei";
}
.introchange3 {
  left: 110px;
  top: 785px;
  position: absolute;
  font: 14px/43px"Microsoft YaHei";
}
/*JACKPOT SIDE */

.Jacpots_1 {
  left: 110px;
  top: 545px;
  position: absolute;
  font: 14px/43px"Microsoft YaHei";
}
.introchange1 {
  left: 110px;
  top: 575px;
  position: absolute;
  font: 14px/43px"Microsoft YaHei";
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="clearfix">
  <br> 
  <li>
    <div id="ubercontainer">
      <div id="container">
        <img src="../images/sideGAME5捕获.jpg" / class="sideGMimg5" " >
        <span class="Jacpots_1">Major Millions</span><br />
        <span id="firstword" class="introchange1">$6 231 515.23</span>  
        <span class="Jacpots_2">Mega Moolah</span><br />
        <span id="secondword" class="introchange2">$6 231 515.23</span>  
        <span class="Jacpots_3">Mega Moolah Isis</span><br />
        <span id="thirdword" class="introchange3">$6 231 515.23</span>  
      </div>
    </div>
    <!-- <span class="Jacpots_1">abc</span> -->
  </li>
  </br>
</ul>
&#13;
&#13;
&#13;

我的形象: enter image description here

1 个答案:

答案 0 :(得分:1)

我想我错过了一些东西,因为我忘了包含js:

<script src="..js/velocity.min.js"></script>
<script src="..js/velocity.ui.min.js"></script>

现在正在努力。