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