Event handler Example

Answer Posted / hrpatelsoft@gmail.com

<html>
<head>
<title>DOM!!!</title>
</head>
<body>
<input type="button" id="btnClick" value="Click Me!!" />
<script type="text/javascript">
document.getElementById("btnClick").addEventListener("click", clicked);
function clicked()
{
alert("You clicked me!!!");
}
</script>
</body>
</html>

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is strict mode in javascript?

629


How can I prevent others from reading/stealing my scripts or images?

546


What are escape characters?

555


How do you check if a variable is an object

627


How to define a anonymous function?

621






Can array in javascript be extended?

572


Explain typecasting in javascript?

554


What are JavaScript Cookies?

578


How to use strings as array indexes using javascript?

612


Is notepad ++ an ide?

596


Why javascript is called as script for all browsers?

551


What kind of conditional statements does JavaScript support?

612


What is the disadvantage of javascript?

546


How to convert a string to a number using javascript?

574


Why javascript is called lightweight language?

582