admin管理员组文章数量:1332383
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">
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">
Share
Improve this question
edited Dec 12, 2012 at 8:40
Cerbrus
73k19 gold badges136 silver badges150 bronze badges
asked Dec 12, 2012 at 7:51
Adesh singhAdesh singh
2,1339 gold badges24 silver badges36 bronze badges
3
- Don't you think it should be: function my(){ document.getElementById("abc").innerHTML="hello"; } – Akhil Sekharan Commented Dec 12, 2012 at 7:53
- you have to add function <script type="text/javascript"> function my() document.getElementById("abc").innerHTML="hello"; } </script> – user7282 Commented Dec 12, 2012 at 7:55
-
1
check your script, have you forget to put
{
afterfunction my()
? – vusan Commented Dec 12, 2012 at 9:58
2 Answers
Reset to default 2Missing the function
keyword
<script type="text/javascript">
function my(){
// Your code here
}
</script>
please define your my function correctly like this:
function my() {
document.getElementById("abc").innerHTML="hello";
}
本文标签: How to call javascript file in htmlStack Overflow
版权声明:本文标题:How to call javascript file in html - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742288607a2447380.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论