javascript链接onclick到.js到文件 [英] javascript linking onclick to a .js to a file
本文介绍了javascript链接onclick到.js到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个 .js
文件,然后将其包含在HTML页面中:
I created a .js
file, and then included it in the HTML pages by:
<script type="text/javascript" src="yourexternalfile.js"></script>
如何调用 .js $ c $的功能c>文件使用
onclick =....
?
我知道它会是这样的:
I know that it will be something like:
<input type="BUTTON" value="Exit" onclick="javascript: ???;" >
但我无法理解......
but I can't figure it out...
推荐答案
如果您使用的是JQuery,可以这样做,
If you are using JQuery, you can do it like this,
<input type="button" onclick="javascript: $.getScript('../scripts/yourfilepath' , function (){ youFunctionCall() ; } );" />
这将在按钮被cliked时下载JS文件并执行内部调用的函数。
This will download the JS file when the button is cliked and shall execute the function called within.
这篇关于javascript链接onclick到.js到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文