Home > Web Front-end > JS Tutorial > jQuery controls the hover effect of images (smartRollover.js)_jquery

jQuery controls the hover effect of images (smartRollover.js)_jquery

WBOY
Release: 2016-05-16 17:55:00
Original
989 people have browsed it

The advantage of using js to implement is: if there are many hover effects of images in a website, each one may need to be controlled by css, so the code will be redundant. But with js control, no matter how many pictures there are, the hover effect can use the same js, but it must be ensured that the out/off effects and over/on effects of the pictures are named regularly, such as:
navi01_out.jpg/navi01_off. jpg
navi01_over.jpg/nvai02_on.jpg
This way js control is very convenient. A matching name is found and replaced with another name on hover.

Today I want to use jQuery to control the effect:
The code is as follows:

Copy the code The code is as follows:



$img can be specified by you, you can specify it as other
For example: var $img = $("img.imgover") ; Indicates all images whose img class is imgover
Others can be customized according to your needs. But you must ensure that the pictures are named regularly
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template