current position:Home>Can jQuery listen for events

Can jQuery listen for events

2022-04-29 17:26:35Billion 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. .

jquery Can you listen to events

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>

jquery Can you listen to events

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>

jquery Can you listen to events

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>

jquery Can you listen to events

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>

jquery Can you listen to events

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

Random recommended