JavaScript event App

Source: Internet
Author: User

One: To bind the button to the order to click the event


<title></title>
<script type= "Text/javascript" >
function Showvalue (BTN) {
alert (Btn.value);
}
Console output from console

</script>

<body>
<!--here, when calling the Showvalue function, pass in a this keyword as an argument, where this represents the current button object--
<input type= "button" value= "Pushbutton 1" onclick= "showvalue (this);" ><br>
<input type= "button" value= "Pushbutton 2" onclick= "Showvalue (this);" ><br>
<input type= "button" value= "Pushbutton 3" onclick= "Showvalue (this);" ><br>
</body>

Two: Binding cursor events for text boxes

You need to bind the Onblue (Lost cursor event) event to the text box, and the function only serves this text box, so it can be handled in the form of an anonymous function


<title> Untitled Document </title>
<script type= "Text/javascript" >
It is necessary to ensure that the page document is loaded or the text box object cannot be obtained
Window.onload=function () {
Get a text box object by using the document.getElementById () function
var cuttxt =document.getelementbyid (' Txtresult ');
Bind a onblur event to a text box
Cuttxt.onblur=function () {
This represents the current text box object that called this function
alert (this.value);
}
}

</script>

<body>
<input type= "text" id= "Txtresult" >
<input type= "button" value= "buttons" ><br>

</body>

JavaScript event App

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.