Home >Web Front-end >JS Tutorial >jQuery image switching plug-in (less code)_jquery

jQuery image switching plug-in (less code)_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 17:54:051083browse
Copy code The code is as follows:

// JavaScript Document
;(function($){
$.fn.extend({
"zj_ppt":function(value){

//Default parameter definition
var $this = $(this);
value = $ .extend({
"time":2000, //Interval change animation time
"con":0,
"sto":true,
"count":"count", // Switch the parent class name of the small picture
"src":"src", //Switch the small picture path
"src_cur":"src_cur" //Current switching small picture path
}, value);

//Picture switching function
function autopic(){
$("li",$this[0]).hide();
$("li:eq(" value.con ")",$this[0]).show();
$(value.count).find("ul li img").attr("src",value.src);
$(value.count).find("ul li img:eq(" value.con ")").attr("src",value.src_cur);
if(value.con>$("li ",$this[0]).length-2){
value.con = 0;
}else{
value.con = 1;
}
}

//How often to perform picture switching
function sett(){
if(value.sto){autopic()};
setTimeout(sett,value.time);
}

//Switch the image when the mouse is hovering, and stop automatic switching
$(value.count).find("ul li").hover(function(){
var _index = $(this).index();
value.con = _index;
value.sto = false;
autopic();
},function(){
var _index = $ (this).index();
value.sto = true;
value.con = _index;

});

sett();

//Return the original object to connect to other JQuery methods
return $this;
}
});
})(jQuery);

The above is part of the plug-in code;

You can download the demo below /201205/yuanma/myPPT_jb51.rar
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