demo01.html
Home Web Front-end JS Tutorial jquery focus image switching (digital annotation/manual/auto play/horizontal scrolling)_jquery

jquery focus image switching (digital annotation/manual/auto play/horizontal scrolling)_jquery

May 16, 2016 pm 05:42 PM
Picture switching Horizontal scrolling Autoplay

jquery focus image switching (digital annotation/manual/auto play/horizontal scrolling)_jquery
demo01.html
复制代码 代码如下:





手动滚动图片









  • jquery focus image switching (digital annotation/manual/auto play/horizontal scrolling)_jquery

  • images/2.jpg

  • images/3.jpg

  • images/4.jpg

  • images/5.jpg

  • images/6.jpg







imgfocus-0.1.0.js
复制代码 代码如下:

/**
* 手动滚动图片
*
**/
$.extend({
imgfocus: function(opt, callback) {
//alert("suc");
this.defaults = {
// 滚动区域id
objId: "",
// 是否在大图下方显示标题
showTitle: false,
// 每行的宽度
width: 300,
// div的高度
height: 100,
// 每次滚动的行数
line: 1,
// 自动滚动的行数
autoLine: 1,
// 动作时间
speed: 0,
// 滚动间隔
interval: 3000,
// 图片根目录
imgPath: "",
// 间隔句柄,不需要设置,只是作为标识使用
picTimer: 0,
// 按钮透明度
opacity: 0.3
};
//参数初始化
var opts = $.extend(this.defaults, opt);
// 定义外层元素样式
$("#" + opts.objId).css({
"position": "relative",
"overflow": "hidden",
"width": (opts.line * opts.width) + "px"
});
// 定义ul样式
$("#" + opts.objId + " ul").css({
"width": opts.width * $("#" + opts.objId + " ul").find("li").size() + "px",
"height": opts.height + "px"
});
// 定义li样式
$("#" + opts.objId + " ul li").css({
"display": "block",
"float": "left",
"width": opts.width + "px",
"height": opts.height + "px"
});
// 定义img样式
$("#" + opts.objId + " ul li img:first").css({
"display": "block",
"float": "left",
"width": opts.width + "px",
"height": opts.height + "px"
});
if (opts.showTitle) {
$("#" + opts.objId).append("
");
$("#imgfocus_banner").css({
"width": opts.width + "px",
"height": "20px",
"background": "#333",
"position": "absolute",
opacity: 0.7,
"text-align": "center",
"color": "#FFF",
"left": "0px",
"top": (opts.height - 20) + "px"
});
$("#imgfocus_banner").html("
");
$("#imgfocus_banner_title").text("text");
$("#imgfocus_banner_title").css({
"display": "block",
"float": "left",
"width": (opts.width - 20 * $("#" + opts.objId + " ul li").size()) + "px",
"height": "20px"
});
$("#" + opts.objId + " ul li").each(function(index) {
$(this).attr("index", index);
$("#imgfocus_banner").append("
" + (index + 1) + "
");
var bgColor;
$("#imgfocus_banner_squ" index).mouseover(function() {
bgColor = $(this).css("배경");
$( this).css({
"배경": "#CC0"
})
}).mouseleave(function() {
$(this).css({
" background": bgColor
});
});
// 数字块点击事件
$("#imgfocus_banner_squ" index).click(function() {

var length = $("#" opts.objId " ul li[index=" index "]").prevAll().size()
var scrollWidth = 0 - length * opts.width - (0 - $( "#" opts.objId).find("ul:first").css("margin-left").replace("px", ""))
$("#" opts.objId). find("ul:first").animate({
marginLeft: scrollWidth
},
6,
function() {
for (i = 1; i $("#" opts.objId).find("li:first").appendTo($("#" opts.objId).find("ul:first"))
}
$("#" opts.objId).find("ul:first").css({
marginLeft: 0
})
var index = $("#" opts .objId).find("li:first").attr("index");
// 数字标签전체 부분变灰color
$(".imgfocus_banner_squ").css({
"배경" : "#CCC"
})
// 活动的数字标签变红color
$("#imgfocus_banner_squ" index).css({
"배경": "#C00"
});
bgColor = "배경:#C00";
변경제목();
});
});
});
// 数字块样式
$(".imgfocus_banner_squ").css({
"display": "block",
"float": "left",
"margin" : "1px",
"너비": "18px",
"높이": "18px",
"색상": "#000",
"배경": "#CCC"
});
// 第一个数字块样式
$(".imgfocus_banner_squ:first").css({
"배경": "#C00"
});
}
/**
* 자동 가로 스크롤
*/
function scrollLeft() {
var scrollWidth = 0 - opts.autoLine * opts.width - (0 - $("#" opts.objId ).find("ul:first").css("margin-left").replace("px", ""));
$("#" opts.objId).find("ul:first").animate({
marginLeft: scrollWidth
},
opts.speed,
function() {
for (i = 1; i $("#" opts.objId).find("li:first").appendTo($("#" opts .objId).find("ul:first"));
}
$("#" opts.objId).find("ul:first").css({
marginLeft: 0
});
var index = $("#" opts.objId).find("li:first").attr("index");
changeTitle()// 数字标签전체부变灰color
$(".imgfocus_banner_squ").css({
"배경": "#CCC"
})
// 活动的数字标签变红color
$ ("#imgfocus_banner_squ" index).css({
"배경": "#C00"
})
});
};
/**
* 제목 변경
*/
함수changeTitle(){
$("#imgfocus_banner_title").text($("#" opts.objId).find("li:first img: 첫 번째").attr("alt"));
}
/**
* 마우스를 위로 슬라이드한 후 버튼 표시
*/
$("#" opts.objId).hover(function() {
$("#button_left").css({
불투명도: 1
});
$("#button_right").css({
불투명도: 1
})
},
function() {
$("#button_left").css({
불투명도: opts.opacity
})
$("#button_right").css({
불투명도: opts.opacity
});
}).trigger("mouseleave");
/**
* 첫 번째로 실행되는 기능
* 초점 영상 위로 마우스를 슬라이드하면 자동 재생을 중지하고, 마우스를 슬라이드하면 자동 재생을 시작합니다
*/
// 初始化标题
changeTitle();
$("#" opts.objId).hover(function() {
clearInterval(opts.picTimer);
},
function() {
opts.picTimer = setInterval( function() {
scrollLeft();
},
opts.interval); // 自动播放的间隔,单位:毫秒
}).trigger("mouseleave");
}
});

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to automatically play the next page after setting up a PPT slideshow How to automatically play the next page after setting up a PPT slideshow Mar 26, 2024 pm 03:26 PM

1. Open a PPT, switch the tab to [Slide Show], and find the [Set Slide Show] option under the menu bar. 2. Set the [Film Changing Method] under this option to [If rehearsal time exists, use it], confirm and exit. 3. Still in the [Slide Show] option bar, check [Use Timing]. The above three steps must be set, otherwise automatic switching will not be possible. 4. Switch to the [Design] tab, first set a switching animation for the slide, and set the [mouse-click] slide change to the timer [automatic slide change]. As shown in the figure, it is set to automatically change 1s after the slide show on the page is completed. Switch to next page.

How to achieve horizontal scrolling effect through CSS Flex layout How to achieve horizontal scrolling effect through CSS Flex layout Sep 27, 2023 pm 02:05 PM

Summary of how to achieve horizontal scrolling effect through CssFlex elastic layout: In web development, sometimes we need to display a series of items in a container and hope that these items can scroll horizontally. At this time, you can use CSSFlex elastic layout to achieve the horizontal scrolling effect. We can easily achieve this effect by adjusting the properties of the container with simple CSS code. In this article, I will introduce how to use CSSFlex to achieve a horizontal scrolling effect and provide specific code examples. CSSFl

How to implement the automatic playback function of carousel images in JavaScript? How to implement the automatic playback function of carousel images in JavaScript? Oct 20, 2023 am 08:03 AM

How does JavaScript implement the automatic play function of carousel images? With the rapid development of the Internet, carousel images have become one of the commonly used elements in web design. Carousel pictures can not only display multiple pictures to users, but also improve user experience through the automatic playback function. JavaScript is one of the important tools for realizing the automatic playback function of carousels. This article will introduce how JavaScript implements the automatic playback function of carousel images, and provide corresponding code examples. First, we need to prepare some basic

How to achieve seamless left and right sliding switching effect of images in JavaScript? How to achieve seamless left and right sliding switching effect of images in JavaScript? Oct 19, 2023 am 08:56 AM

How to achieve seamless left and right sliding switching effect of images with JavaScript? With the development of the Internet, images are often used as important elements of the page in web design. The switching effect of pictures plays an important impact on the beauty and interactivity of the page. In this article, we will explore how to use JavaScript to achieve a seamless left-right sliding switching effect of images, and attach specific code examples. To achieve the seamless left and right sliding switching effect of pictures, you first need to do the following: Create a picture container and use

How to automatically play the next video in Douyin Express Edition How to set auto-play in Douyin Express Edition How to automatically play the next video in Douyin Express Edition How to set auto-play in Douyin Express Edition Mar 29, 2024 am 08:36 AM

The Douyin Express version APP is still a platform that many friends choose to use to watch videos. Some of the functions here are quite good and can easily meet your various uses, allowing everyone to watch videos here. It has become more convenient. Sometimes when people watch videos here, they scroll down and down. It is more troublesome to be able to watch videos all the time. At this time, everyone can choose to use the auto-play function on the platform. , as long as you set up the auto-play function, it can automatically switch to play the next video for you, which is more convenient. Friends who need it can take a look at the setting method below. How to automatically play the next video on Douyin Express Edition: First step, click on the upper right corner of my page on Douyin Express Edition

How to set up auto-play in edge browser? How to set up auto-play in edge browser? Mar 14, 2024 am 09:00 AM

Nowadays, many users are using the edge browser, but in the process, a problem was discovered. The media displayed in the browser cannot be played automatically. It needs to be manually clicked to play. Many users want to know how to set up the edge browser. Autoplay? In response to this problem, the editor of this software tutorial will share the specific operation steps with the majority of users, hoping to bring help to the majority of friends. How to set up auto-play in Edge browser: 1. Enter the software, click the "..." icon in the upper right corner of the page, and select "Settings" from the options given below. 2. In the new interface, click "Advanced" on the left

The operation process of setting several pictures to automatically play in a PPT slideshow The operation process of setting several pictures to automatically play in a PPT slideshow Mar 26, 2024 pm 02:01 PM

1. Open the slideshow. 2. Click Start, Slide Layout, and select Blank Layout. This will help prevent the image from looking ugly after inserting it. 3. Click Insert, Picture, find the picture in the file, click it, and then click OK to insert the picture into the slide. You can then crop and resize the image in the upper right corner. 4. Click Animation and then click Custom Animation. Click on the right to add an effect, enter, randomly select an effect, and click OK. 5. On the right side, the status of the modification start when adding the effect is changed from when clicked to after. The design is now complete.

Methods and techniques on how to achieve image carousel effects through pure CSS Methods and techniques on how to achieve image carousel effects through pure CSS Oct 18, 2023 am 08:27 AM

Methods and techniques on how to achieve image carousel effects through pure CSS. In modern web design, image carousel effects are often used to display multiple images or advertisements in turn. There are many ways to achieve an image carousel effect, one of the common ways is to use CSS animation. This article will introduce methods and techniques on how to achieve image carousel effects through pure CSS, and provide specific code examples. 1. HTML structure First, the image elements for carousel need to be prepared in HTML. Here is a simple HTML structure example: &l

See all articles