current position:Home>Can jQuery listen for events
Can jQuery listen for events
2022-04-29 17:26:35【Billion cloud speed】
jquery Can you listen to events
Today I'd like to share with you jquery Can you listen to the relevant knowledge points of the event , Detailed content , Clear logic , I believe most people still know too much about this knowledge , So share this article for your reference , I hope you will gain something after reading this article , Now let's take a look .
jquery Can listen for events .jquery Provide a variety of methods to listen to events :1、click(), Can listen for click events , And specify the event handling function ;2、change(), Can listen for change events , And specify the event handling function ;3、dblclick() , Double click event can be monitored ;4、hover() etc. .
The operating environment of this tutorial :windows7 System 、jquery1.10.2 edition 、Dell G3 The computer .
jquery Can listen for events .
jquery Provides a variety of methods to listen to events , for example click()、on() Other methods . Here are some methods .
1、click() Method :
click() The method stipulates that when click Function to run at event time
Example : single click <p> Element, the alert text
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <script src="js/jquery-1.10.2.min.js"></script> <script> $(document).ready(function() { $("p").click(function() { alert(" The paragraph was clicked ."); }); }); </script> </head> <body> <p> Click on this paragraph .</p> </body></html>
2、change() Method
change() The method stipulates that when change Function to run at event time .
Example : When <input> Alert text when field changes
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <script src="js/jquery-1.10.2.min.js"></script> <script> $(document).ready(function(){ $("input").change(function(){ alert(" The text has been modified "); }); }); </script> </head> <body> <input type="text"> <p> Write something in the input box , Then press enter Key or click outside the input box .</p> </body></html>
3、dblclick()
dblclick() The method stipulates that when double-click Function to run at event time .
Example : double-click <p> Element, the alert text
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <script src="js/jquery-1.10.2.min.js"></script> <script> $(document).ready(function() { $("p").dblclick(function() { alert(" This paragraph is double clicked ."); }); }); </script> </head> <body> <p> Double click this paragraph .</p> </body></html>
4、hover() Method
hover() Method specifies two functions to run when the mouse pointer hovers over the selected element .
Methods the trigger mouseenter and mouseleave event .
Example : When the mouse pointer hovers over it , change <p> The background color of the element
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <script src="js/jquery-1.10.2.min.js"></script> <script> $(document).ready(function() { $("p").hover(function() { $("p").css("background-color", "yellow"); }, function() { $("p").css("background-color", "pink"); }); }); </script> </head> <body> <p> Move the mouse to the paragraph .</p> </body></html>
Other ways to listen for events
Method | describe |
---|---|
bind() | Add event handler to element |
blur() | add to / Trigger loss of focus event |
delegate() | Add a handler to the current or future child elements of the matching element |
die() | In version 1.9 Be removed in the . Remove all passes live() Event handler added by method |
error() | In version 1.8 Abandoned in . add to / Trigger error event |
focus() | add to / Trigger focus event |
focusin() | Add event handler to focusin event |
focusout() | Add event handler to focusout event |
keydown() | add to / Trigger keydown event |
keypress() | add to / Trigger keypress event |
keyup() | add to / Trigger keyup event |
live() | In version 1.9 Be removed in the . Add one or more event handlers to current or future selected elements |
load() | In version 1.8 Abandoned in . Add an event handler to the load event |
mousedown() | add to / Trigger mousedown event |
mouseenter() | add to / Trigger mouseenter event |
mouseleave() | add to / Trigger mouseleave event |
mousemove() | add to / Trigger mousemove event |
mouseout() | add to / Trigger mouseout event |
mouseover() | add to / Trigger mouseover event |
mouseup() | add to / Trigger mouseup event |
off() | Remove pass on() Event handler added by method |
on() | Add event handler to element |
one() | Add one or more event handlers to the selected element . The handler can only be triggered once per element |
resize() | add to / Trigger resize event |
scroll() | add to / Trigger scroll event |
select() | add to / Trigger select event |
submit() | add to / Trigger submit event |
trigger() | Trigger all events bound to the selected element |
triggerHandler() | Triggers all functions bound to the specified event of the selected element |
unbind() | Remove the added event handler from the selected element |
undelegate() | Remove event handlers from current or future selected elements |
unload() | In version 1.8 Abandoned in . Add event handler to unload event |
contextmenu() | Add event handler to contextmenu event |
That's all “jquery Can you listen to events ” All the content of this article , Thank you for reading ! I believe you will gain a lot after reading this article , Xiaobian will update different knowledge for you every day , If you want to learn more , Please pay attention to the Yisu cloud industry information channel .
copyright notice
author[Billion cloud speed],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291539467157.html
The sidebar is recommended
- 07 Chrome browser captures hover element style
- WebGIS development training (ArcGIS API for JavaScript)
- Solution to the blank page of the project created by create react app after packaging
- 19. Html2canvas implements ArcGIS API for JavaScript 4 X screenshot function
- Introduction to JavaScript API for ArcGIS 13
- Development of ArcGIS API for JavaScript under mainstream front-end framework
- Nginx learning notes
- Less learning notes tutorial
- Vue2 cannot get the value in props in the data of the child component, or it is always the default value (the value of the parent component comes from asynchrony)
- LeetCode 217. Determine whether there are duplicate elements in the array
guess what you like
I'll write a website collection station myself. Do you think it's ok? [HTML + CSS + JS] Tan Zi
Front end browser debugging tips
Application of anti chattering and throttling in JavaScript
How to create JavaScript custom events
Several ways of hiding elements in CSS
node. Js-3 step out the use of a server and express package
CSS matrix function
Fastapi series - synchronous and asynchronous mutual conversion processing practice
How to extend the functionality of Axios without interceptors
Read pseudo classes and pseudo elements
Random recommended
- About node JS server related concepts
- Access control module (2)
- About virtual lists
- Developing figma plug-in using Vue 3 + vite
- Learn more about the garbage collection engine of chrome V8 JavaScript engine
- Vue3 uses vite instead of webpack
- How to upload applet code through node? Just take a look
- Using H5 video tag in Vue to play local video in pop-up window
- What is the difference between classes in Es5 and ES6?
- [Vue] play with the slot
- [Part 4 of front-end deployment] using docker to build cache and multi-stage construction to optimize single page applications
- Vue2 simple use of vant (based on Vue CLI)
- node. JS server
- React uses concurrent mode. When the rendering phase exceeds the time slice, high priority tasks jump the queue. How will the lanes on the fiber of the previous task be solved
- Vuecli2 multi page, how to remove HTML suffix
- Vue router dynamically modifies routing parameters
- How to use webpack or configure quasar after context isolation is turned on by electron?
- Vue3 how do parent components call child component methods
- Es learning notes (I): http request
- 【Java WEB】AJAX
- Java project: nursing home management system (java + springboot + thymeleaf + HTML + JS + MySQL)
- Java project: drug management system (java + springboot + HTML + layui + bootstrap + seals + MySQL)
- Java project: agricultural material management system (java + springboot + easyUI + HTML + Maven + MySQL)
- How do Vue, native JS and jQuery feel about development
- The Ajax backend accepts post data and writes it directly to the database
- Java project: agricultural material management system (java + springboot + easyUI + HTML + Maven + MySQL)
- Brother Lao Yu takes you to play with esp32:14 and personally make a two-way wireless remote control (I)
- How to create JavaScript custom events
- A king's time, I learned nginx
- Vue quick start (with actual small items: Notepad, weather forecast, music player)
- Vue: convert user input to numeric type
- - Status code: 404 for http://mirrors.cloud.aliyuncs.com/centos/8/AppStream/x86_64/os/repodata/repom
- vue. config. Understanding of agent in JS
- After the node is successfully installed, CMD can be executed, but the compiler webstorm runs NPM install and prompts that there is no solution to this command
- How to develop and deploy front-end code in large companies
- Vue assigns permissions to buttons through instructions
- [development diary from 22 years to April] Vue problems encountered in actual projects and their solutions
- [methodology 1] CSS development skills - global style setting and local style
- vue3. 0 dynamically bind and obtain DOM through ref;
- How to use HTML for touch event in mobile terminal