lundi 11 mai 2015

Javascript doesn't work in html file

I have html file:

<html>
<head>
<script type="text/javascript" src="new.js"></script>

</head>
<body>
   <p id="contentBI" >you should click here! </p>
</body>
</html>

and javascript file:

function doAlert(){
      alert("hi!");
  }

function addevent (){
   theBI=document.getElementById("contentBI");
   theBI.addEventListener("click",doAlert);
}
document.addEventListener("load",addevent);

Javascript doesn't run.

Aucun commentaire:

Enregistrer un commentaire