Add click action to a Button in JavaScript
Description
The following code shows how to add click action to a Button.
Example
<!-- www . jav a 2s. co m-->
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<button id="pressme">Press Me</button>
<script>
document.getElementById("pressme").onclick = function(e) {
document.writeln("java2s.com");
};
</script>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Button
Access form button with its name through do...
Access form with form name through document...
Add click event handler to input onClick ev...
Change input button color and background co...
Get current value of the submit button whic...
List properties from a form button in JavaS...
Return false in form button click event to ...
Use Image as the submit button in JavaScrip...
Access form button with its name through do...
Access form with form name through document...
Add click action to a Button in JavaScript
Add click event handler for input button in...Add click event handler to input onClick ev...
Change input button color and background co...
Get current value of the submit button whic...
List properties from a form button in JavaS...
Return false in form button click event to ...
Use Image as the submit button in JavaScrip...