Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Can jquery listen for events?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Today, the editor will share with you the relevant knowledge about whether jquery can monitor events. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

Jquery can listen for events. Jquery provides a variety of listening event methods: 1, click (), can listen to click events and specify event handling functions; 2, change (), can listen to change events and specify event handling functions; 3, dblclick (), can listen to double-click events; 4, hover (), etc.

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

Jquery can listen for events.

Jquery provides a variety of methods to listen for events, such as click (), on (), and so on. Here are some methods.

1. Click () method:

The click () method specifies the function to run when the click event occurs

Example: click

Element when the alert text

$(document) .ready (function () {$("p") .click (function () {alert ("paragraph has been clicked.") ;})

Click on this paragraph.

2. Change () method

The change () method specifies the function to run when the change event occurs.

Example: alert text when the field changes

$(document) .ready (function () {$("input") .change (function () {alert ("text has been modified");})

Write something in the input box, then press the enter key or click outside the input box.

3. Dblclick ()

The dblclick () method specifies the function to run when a double-click event occurs.

Example: double-click

Element when the alert text

$(document) .ready (function () {$("p") .dblclick (function () {alert ("this paragraph is double-clicked.") ;})

Double-click the paragraph.

4. Hover () method

The hover () method specifies two functions to run when the mouse pointer hovers over the selected element.

Method triggers mouseenter and mouseleave events.

Example: when the mouse pointer hovers over it, change the

The background color of the element

$(document) .ready (function () {$("p") .hover (function () {$("p") .css ("background-color", "yellow") }, function () {$("p") .css ("background-color", "pink");})

Move the mouse to the paragraph.

Other ways to listen for events

Method description bind () add event handler blur () add / trigger loss of focus event delegate () add handler die () to current or future child elements of matching elements is removed in version 1.9. Remove all event handlers added by the live () method error () is deprecated in version 1.8. Add / trigger error event focus () add / trigger focus event focusin () add event handler to focusin event focusout () add event handler to focusout event keydown () add / trigger keydown event keypress () add / trigger keypress event keyup () add / trigger keyup event live () is removed in version 1.9. Adding one or more event handlers to the current or future selected element load () is discarded in version 1.8. Add an event handler to load event mousedown () add / trigger mousedown event mouseenter () add / trigger mouseenter event mouseleave () add / trigger mouseleave event mousemove () add / trigger mousemove event mouseout () add / trigger mouseout event mouseover () add / trigger mouseover event mouseup () add / trigger mouseup event off () remove the event handler on () added to the element through the on () method Add an event handler one () to add one or more event handlers to the selected element. The handler can only be triggered once per element by resize () add / trigger resize event scroll () add / trigger scroll event select () add / trigger select event submit () add / trigger submit event trigger () trigger all events bound to the selected element triggerHandler () trigger all functions unbind () bound to the specified event of the selected element remove the added event handler from the selected element Undelegate () removes the event handler unload () from the current or future selected elements and is deprecated in version 1.8. Add event handlers to unload events contextmenu () add event handlers to contextmenu events above is all the content of this article "whether jquery can listen for events". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report