Introduction to jquery click ([data],fn) Usage Method Example

Source: Internet
Author: User
Probably the meaning is to trigger each matching element Click event, this article through an example for everybody detailed introduction jquery click ([Data],fn) The use method, the interest friend may refer to Ha, hoped that has the help to everybody

Click ([[DATA],FN])
return value: JQuery
Overview
Triggers the Click event for each matching element.

This function invokes all functions that perform binding to the Click event.

Parameters
fnFunctionV1.0
The handler function that is bound in each matching element's Click event.

[data],fnstring,functionv1.4.3
Data:click ([Data], FN) can be passed in to the Data for the function fn processing.

fn: The handler function that is bound in each matching element's Click event.

Sample
Describe:
Triggers click events for all paragraphs within the page

JQuery Code:
$ ("P"). Click (), Description:
Click and hide all paragraphs in the page.

JQuery Code:
$ ("P"). Click (function () {$ (this). Hide ();}); The above is a jquery reference manual that looks at a number of references, but none of the [data] parameters are described in detail

Parameter data is an additional data object passed to the event object as a Event.data property value
Parameter FN is a handler in the event that is bound to each selection element

Copy Code code as follows:


<! DOCTYPE html>
JQuery [data] parameter usage description
</title><link href= "css/main.css" type= "Text/css" rel= "stylesheet"/>
<script src= " Jquery-1.8.3.min.js "type=" Text/javascript "></script>

<script type=" Text/javascript ">
$ (function () {
var message= "Passes this information to the FN function";
$ (". txt"). Click ({msg:message},function (event) {$ ("#idTip"). Show (). HTML (EVENT.DATA.MSG); /Set Text
});
</script>
<body>
<input class= "txt" ></div>
<div id= "IdT IP "></div>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.