Home  >  Article  >  Web Front-end  >  jQuery loop scrolling display code can be applied to text and pictures_jquery

jQuery loop scrolling display code can be applied to text and pictures_jquery

WBOY
WBOYOriginal
2016-05-16 17:53:44952browse

I saw some students using Adam Cai's code, which seemed a little complicated and not enough jQuery. I wrote a version based on the idea of ​​just getting started with jQuery. The code is less used and simpler.

Online demo: http://demo.jb51.net/js/2012/jquery_xhpic/
jQuery loop scrolling display code can be applied to text and pictures_jquery
[JavaScript] code

Copy code The code is as follows:

$(document).ready(function(){
$("# sItem li:not(:first)").css("display","none");
var B=$("#sItem li:last");
var C=$("#sItem li:first");
setInterval(function(){
if(B.is(":visible")){
C.fadeIn(500).addClass("in");B. hide()
}else{
$("#sItem li:visible").addClass("in");
$("#sItem li.in").next().fadeIn( 500);
$("li.in").hide().removeClass("in")}
},3000) //Switch one every 3 seconds, you can change it as needed
})

HTML part:
Copy code The code is as follows:


  • Text or picture

  • Text or picture

  • Text or picture


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