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 global variable in javascript?

493


What are global variables? How are these variable declared and what are the problems associated with using them?

516


What does “1?+2+4 Evaluate to? What about 5 + 4 + “3??

548


What do you mean by script?

444


Is javascript frontend or backend?

443






What is missing in my code? function numberTally(numList) { var evenTotal = 0; var oddTotal = 0; for (var i = 0; i <= numList.length; i++) { if i % 2 { // i is odd oddTotal += numList[i]; // or oddTotal = oddTotal + numList[i]; } else { // i is even evenTotal + numList[i]; } } alert(oddTotal); return evenTotal; }

2895


What is the difference between the operators '==' and '==='?

517


How much do javascript programmers make?

478


How to get the primitive value of a string in Javascript?

526


What is decodeuri(), encodeuri() in javascript?

548


How can I learn coding fast?

473


What does question mark mean in react?

471


What's the date object using javascript?

542


How long does it take to get good at javascript?

451


Explain a story about javascript performance problems?

490