jquery 数字滚动到指定数字

<div id="hhui" class="hhui">
<div class="mid ys2">
<div class="mt mt1">
<div class="mtimg"><img src="/images/b1.jpg" alt="" width="69" height="69" /></div>
<div class="mtttt">18</div>
<div class="mttcc">Has rich industrial production experience, has been engaged in the development of machine tools</div>
</div>
<div class="mt mt2">
<div class="mtimg"><img src="/images/b2.jpg" alt="" width="69" height="69" /></div>
<div class="mtttt">40000</div>
<div class="mttcc">The company occupies more than 40,000 square meters, plant more than 20,000 square meters</div>
</div>
<div class="mt mt3">
<div class="mtimg"><img src="/images/b3.jpg" alt="" width="69" height="69" /></div>
<div class="mtttt">120</div>
<div class="mttcc">Engineers and technicians account for 20% of the total number of employees</div>
</div>
<div class="mt mt4 last">
<div class="mtimg"><img src="/images/b4.jpg" alt="" width="69" height="69" /></div>
<div class="mtttt">60</div>
<div class="mttcc">The company has more than 60 models of products</div>
</div>
</div>
<div class="clear">&nbsp;</div>
</div>
<script type="text/javascript">// <![CDATA[
var ais=1;
$(window).scroll(function() {

 var sb=$("#hhui").offset().top;
 var oTop=document.body.scrollTop==0?document.documentElement.scrollTop:document.body.scrollTop;//IE和chrome获取方式不一样
 var sa=oTop-document.body.clientHeight;

if(oTop+$(window).height()-160>sb&& ais==1)
{    console.log(2);
    ais=2;
        $('.mtttt').each(function(){
        $(this).prop('Counters',0).animate({
            Crs: $(this).text()
        },{
            duration: 3000,
            easing: 'swing',
            step: function (now){
                $(this).text(Math.ceil(now));
            }
        });
    });    
}  
});
// ]]></script>

 

posted @ 2018-11-02 10:48  自由无风  阅读(1908)  评论(0编辑  收藏  举报