mukesh kumar

mukesh kumar

  • NA
  • 259
  • 2k

addEventListener not working on content page.

Oct 6 2018 10:58 PM
when i run this code on content page then it's not working and error message comes that "0x800a1391 - JavaScript runtime error: 'btn' is undefined" but when i run this code on html page then it's execute without any errors.
<input type="button" value="Click" id="btn" />
<script type="text/javascript">
btn.addEventListener("mouseover", changeColorOnMouseOver, false);
btn.addEventListener("mouseout", changeColorOnMouseOut, false);

function changeColorOnMouseOver() { = 'red'; = 'yellow';

function changeColorOnMouseOut() { = 'black'; = 'white';

Answers (1)