HTML button onclick calling javascript file not fu

2019-08-29 13:40发布

I imported the javascript file in the head like this :

<script type="text/javascript" src="js/ISO_TR_230-9.js"></script>

That file contains a function calc1 which is set up like this :

function calc1() {}

I am calling calc1 from a button that is set up like this :

<button type="button" onclick="calc1()">Calculate</button>

Upon clicking the button I receive the error calc1 is not defined. Is there anything that could be happening where this occurs?

1条回答
ら.Afraid
2楼-- · 2019-08-29 14:35
<button type="button" onclick="calc1()">Calculate</button>

That style of setting the events is old. I think hast been created when you call it.

so try put the handler in the JS-file. and, window.onload() or Smthn from Jq.

查看更多
登录 后发表回答