3

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">
Cerbrus
  • 65,559
  • 18
  • 128
  • 140
Adesh singh
  • 2,043
  • 9
  • 22
  • 36

2 Answers2

2

Missing the function keyword

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

        // Your code here
   }
</script>
Sushanth --
  • 54,565
  • 8
  • 62
  • 98
2

please define your my function correctly like this:

function my() {
    document.getElementById("abc").innerHTML="hello";
} 
silly
  • 7,565
  • 2
  • 23
  • 36