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
  • 70,800
  • 18
  • 132
  • 147
Adesh singh
  • 2,083
  • 9
  • 24
  • 36

2 Answers2

2

Missing the function keyword

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

        // Your code here
   }
</script>
Sushanth --
  • 55,259
  • 9
  • 66
  • 105
2

please define your my function correctly like this:

function my() {
    document.getElementById("abc").innerHTML="hello";
} 
silly
  • 7,789
  • 2
  • 24
  • 37