In many cases, we actually need to set mouse effects on web pages. Some are automatically generated, such as a link. When the mouse is moved up, it will automatically turn into a hand for clicking. Sometimes an input is entered. box, then the mouse will automatically change into an English capital I. So can we set more objects to look like we need? This is completely possible. Let’s take a look at the effect. How to write the code:"/> In many cases, we actually need to set mouse effects on web pages. Some are automatically generated, such as a link. When the mouse is moved up, it will automatically turn into a hand for clicking. Sometimes an input is entered. box, then the mouse will automatically change into an English capital I. So can we set more objects to look like we need? This is completely possible. Let’s take a look at the effect. How to write the code:">
search
HomeComputer TutorialsComputer KnowledgeAbout css adding button event (how to write css mouse click event)

About css adding button event (how to write css mouse click event)

ainer\">

We often need to set mouse effects on web pages. Some are automatically generated, such as a link link. Then When the mouse is moved up, it will automatically turn into a hand for clicking. Sometimes when there is an input box, the mouse will automatically turn into an English capital I. So can we set more objects to look like we need? This is completely possible, let’s take a look at the effect

Code writing:

<div onmouseover=\"this.className=\'over\';\"><div onmouseover=\"this.className=\'over\'; this.id=\'over\';\"><div onmouseover=\"this.style.background=\'url(bj.png) no-repeat\';\" onmouseout=\"…;…\">

Other mouse events:

onClick: Mouse click event. (Refers to the mouse Generated when pressed and then released.)

onDblClick: Mouse double-click event. (Refers to generated when the mouse is quickly pressed, released, and pressed again.)

onMouseDown: Mouse Press event. (Occurs when the mouse is pressed.)

onMouseUp: Mouse release event. (Refers to the mouse from the pressed state to popping up.)

onMouseMove: Mouse move event . (Refers to moving the mouse on a specific element.)

onMouseOver: Mouse over event. (Refers to, occurs when the pointer moves from the outside to the element.)

onMouseOut: The mouse leaves Event. (Occurs when the mouse leaves a specific element.)

onLoad: Loading event. (Occurs when the image or page ends loading.)

onUnload: Unloading event . (Generated when the visitor leaves the page.)

onScroll: Scroll bar scroll event. (Generated when the visitor uses the scroll to move up or down.)

Case:

Apply this custom style to the image. When previewed in the browser, the image becomes black and white. We define another style ".over". This style has no content and is an empty style. The style sheet code is as follows:

<style type=\"text/css\">  .over {}.out {filter: Gray}</style>

Then add "onMouseOver="this.className='over\'" onMouseOut="this.className='out\'"" to the image tag (IMG), which means that when the mouse passes by, The picture is in the over style, which is a normal color image; when the mouse leaves, the picture is in the out style, which is a black and white image. oMouseOver and onMouseOut are mouse events, this.className="..." means the class name of the current object is..., pay attention to the size Don’t make mistakes when writing, JS is very sensitive to upper and lower case.

The effect is completed. After saving, open it in the browser. The image will be black and white. When the mouse is moved up, the image will turn into color. , when the mouse leaves, the image turns back to black and white. As long as you use your imagination, you can also create many beautiful mouse effects through this.className method.

Mouse pointer:

<span style=\"cursor:crosshair\">十字</span><span style=\"cursor:text\" >文本光标</span><span style=\"cursor:wait\" >等待</span><span style=\"cursor:default\" >默认</span><span style=\"cursor:help\" >问号</span><span style=\"cursor:e-resize\" >左右箭头</span><span style=\"cursor:s-resize\" >上下箭头</span><span style=\"cursor:auto\" >系统自动给出效果</span><span style=\"cursor:url(\'图标的地址\')\" >系统自动给出效果</span>

CSS definition and usage

:hover selector is used to select the element on which the mouse pointer floats.

Tip: The :hover selector can be used on all elements, not just links.

Tip: The :link selector sets the style of links pointing to pages that have not been visited, the :visited selector is used to set links to pages that have been visited, and the :active selector is used for active links.

Note: In the CSS definition, :hover must be placed after :link and :visited (if present) for the style to take effect.

The above is the detailed content of About css adding button event (how to write css mouse click event). For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:晶发科技. If there is any infringement, please contact admin@php.cn delete
Download Hidester VPN/Proxy to Access Your Favorite Content - MiniToolDownload Hidester VPN/Proxy to Access Your Favorite Content - MiniToolApr 22, 2025 am 12:50 AM

Learn about Hidester VPN and Hidester proxy and download Hidester VPN for Windows, Mac, Android, and iOS to use this VPN service to view websites with no limit. For more useful free computer tools and troubleshooting tips, you may visit php.cn Softwa

Windows Keyboard Opening Shortcuts Instead of Typing [Fixed]Windows Keyboard Opening Shortcuts Instead of Typing [Fixed]Apr 22, 2025 am 12:48 AM

Have you ever encountered the trouble of “Windows keyboard opening shortcuts instead of typing”? In this post from php.cn, you will learn how to fix this issue.

Easy Ways to Add the Control Panel Icon to Desktop on Win 10 / 11Easy Ways to Add the Control Panel Icon to Desktop on Win 10 / 11Apr 22, 2025 am 12:46 AM

In this post, php.cn Software will introduce what Control Panel is and how to add the Control Panel icon to desktop on your Windows 10 or Windows 11 computer. You can also learn some related information about desktop icon settings.

Granblue Fantasy Relink Save File Location & Backup Save DataGranblue Fantasy Relink Save File Location & Backup Save DataApr 22, 2025 am 12:45 AM

If you play Granblue Fantasy: Relink on your PC, you may wonder where you can find its save file. In this post, php.cn introduces everything you want to know - Granblue Fantasy Relink save file location and how to back up the savegame of this game.

How to Fix Event ID 1104: The Security Log Is Now Full? - MiniToolHow to Fix Event ID 1104: The Security Log Is Now Full? - MiniToolApr 22, 2025 am 12:44 AM

Event Viewer keeps track of activity for better management. However, if the upper limit of the security log is reached, no more events can be logged. In this post on php.cn Website, we will show you how to deal with Event ID 1104 the security log is

Watch: How to Enable Secure Boot on Gigabyte Motherboard?Watch: How to Enable Secure Boot on Gigabyte Motherboard?Apr 22, 2025 am 12:43 AM

Secure Boot is a security standard that can prevent your computer from booting with untrustworthy software. Enabling it will add an extra layer of security to your device. In this post from php.cn Website, we will show you how to enable Secure Boot o

Windows 11 23H2 Release Date: September 26, 2023 - MiniToolWindows 11 23H2 Release Date: September 26, 2023 - MiniToolApr 22, 2025 am 12:42 AM

Coming to a new year, what Windows 11 users are looking forward to are not only the patch updates but also the annual major update for Windows 11. This post will talk about the Windows 11 23H2 release date. In addition, if you want to recover deleted

How to Turn off Bixby on Samsung Phone? See a Guide! - MiniToolHow to Turn off Bixby on Samsung Phone? See a Guide! - MiniToolApr 22, 2025 am 12:41 AM

Can you completely disable Bixby? How to turn off Bixby on Samsung phones? It is not hard to disable this voice assistant. In this post from php.cn, we will go to any length to help you find the method. Besides, a way to turn off “Hi, Bixby” is also

See all articles

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.