js公告轮播代码

发布时间:2017-2-21 13:19:33 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"js公告轮播代码",主要涉及到js公告轮播代码方面的内容,对于js公告轮播代码感兴趣的同学可以参考一下。

//首页公告 var $announcement = $('#announcement ul'); var cheight = parseInt($('#announcement').css('line-height').split('p')[0]); var announcementLength = $announcement.find('li').length; var nowtop,nexttop; var announcementTimer = setInterval(function (){ nowtop = parseInt($announcement.css('top').split('p')[0]); nexttop = 0; if(nowtop == (-(announcementLength - 1)*cheight)){ nexttop = '0px'; }else{ nexttop = (nowtop - 30) + 'px'; } console.log(nowtop + ' ' + (-(announcementLength - 1)*cheight)); $announcement.animate({top:''+nexttop}); },2000);<div id="announcement"> <ul> <li><a href="#">欢迎来到官方网站1!</a></li> <li><a href="#">欢迎来到官方网站2!</a></li> <li><a href="#">欢迎来到官方网站3!</a></li> <li><a href="#">欢迎来到官方网站4!</a></li> </ul> </div> #announcement{ position:absolute; right:0; top:100px; width:300px; height:30px; line-height:30px; overflow:hidden;} #announcement ul{ position:absolute; top:0;} #announcement li{ height:30px; line-height:30px; overflow:hidden;}

上一篇:lpc1768的网络通讯
下一篇:mac 下安装 tomcat7

相关文章

相关评论