JQuery getting started -- bind an event handler using the one () method (trigger only once)

Source: Internet
Author: User

1. one () method FunctionIs to bind a processing function that only triggers once for the selected element. The syntax format of the called function is one (type, [data], fn)

The parameter type is the event type, that is, the type of event to be triggered. The parameter data is an optional parameter, which indicates that it is used as an event. the data property value is an additional data object passed to the event object. fn is the function to be triggered when an event is bound.

2. Sample Code:
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> Other events </title>
<Script type = "text/javascript" src = "jquery-1.8.3.min.js"> </script>
<Script type = "text/javascript">
$ (Function (){
$ ("# Button"). bind ("click", function (){
$ ("# Button"). attr ("value", "14797710665 ");
});
})
</Script>
</Head>

<Body>
<Div>
<Input id = "button" type = "button" value = "view contact information" class = "btn"/>
</Div>
</Body>
</Html>

3. Preview:


After clicking:

Click "no response ".

Related Article

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.