Home  >  Article  >  Web Front-end  >  Implementation of Sohu-like debate voting animation code based on jQuery (with source code download)_jquery

Implementation of Sohu-like debate voting animation code based on jQuery (with source code download)_jquery

WBOY
WBOYOriginal
2016-05-16 15:14:491438browse

Based on jQuery, the imitation Sohu debate voting animation code is implemented, a personalized cartoon villain pro and con debate voting special effects code. Movement animation effects are smooth and natural. Has a very good user experience. The source code is compatible with the latest mainstream browsers.

Effect demonstration Source code download

html code:

<script type="text/javascript">
$(document).ready(function () {
var a = 500;
var b = 130;
$("#white").animate({ width: 0, left: "250px" }, 1000, function () {
$("#vs").fadeIn("slow", function () {
$("#all").html(a + b); $("#aa").html(a); $("#bb").html(b);
var newLeft = a / (a + b) * 500 - 20 + "px"; //20为vs 的一半
$("#vs").animate({ left: newLeft }, 1000);
$("#red").animate({ width: newLeft }, 1000);
});
});
});
</script>
<div id="box_bg">
<div id="container">
<div id="green" class="line"></div>
<div id="red" class="line"></div>
<div id="white" class="line"></div>
<div id="vs"></div>
</div>
</div>
<div style="width:440px; margin:0px auto;">
<div id="aa2" class="scope">正方<span id="aa"></span>票</div>
<div id="bb2" class="scope">反共<span id="bb"></span>票</div>
<div id="all2" class="scope">总共<span id="all"></span>票</div>
</div>

The above code is based on jQuery to implement Sohu-like debate voting animation code. I hope it will be helpful to everyone!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn