How to realize Click event triggered by Click text in jquery
This article mainly introduces the relevant knowledge of "jquery how to achieve click-to-text trigger click event". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope that this "jquery how to achieve click text trigger click event" article can help you solve the problem.
Implementation method: 1, use click () to bind click events to text elements, and set the handler, syntax "element .click (function () {...})"; 2, use on () to bind click events to text elements, syntax "element .on" ("click", function () {...}) ".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
The method of realizing Click text and trigger Click event in jquery
1. Use click ()
Use click () to bind click events to text elements, and set event handlers.
Syntax:
$(selector) .click (function () {...})
Example:
$(document) .ready (function () {$("p") .click (function () {$("p"). Css ("color", "pink");})
Click on the text paragraph.
2. Use on ()
Use on () to bind click events to text elements, and set event handlers.
Syntax:
$(selector) .on ("click", function () {...})
Example:
$(document) .ready (function () {$("p"). On ("click", function () {$("p"). Css ("background-color", "pink");})
Click on the text paragraph.
This is the end of the introduction on "how to click on text to trigger click events in jquery". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.