Adesh singh
Adesh singh

Reputation: 2133

How to call javascript file in html

I am trying to call innerHtml in JavaScript its working in the same file but not in the separate JavaScript JS file. my working code is

<script type="text/javascript">
   function my()
    document.getElementById("abc").innerHTML="hello";
    } 
    </script>
<div id="abc" onmouseover ="my()"> hi hw ru  </div>

But if I invoke this method in separate JavaScript file its not working even I am giving the source path of the JavaScript file like

<script type="text/javascript" src="js/framemrq.js">

Upvotes: 3

Views: 9916

Answers (2)

silly
silly

Reputation: 7887

please define your my function correctly like this:

function my() {
    document.getElementById("abc").innerHTML="hello";
} 

Upvotes: 2

Sushanth --
Sushanth --

Reputation: 55740

Missing the function keyword

<script type="text/javascript">
  function my(){

        // Your code here
   }
</script>

Upvotes: 2

Related Questions