如何使用外部“.js”档 [英] How to use external ".js" files
问题描述
我有以下两个javascript函数:
$ b $ 1 b
$ b $ pre $ code > showCountry()
2
<$ p $ >
showUser()
我想将它们放在外部。 jsfiles 2 调用这些函数的正确语法是什么? 这样的代码 我希望它能帮助你... I have the following two javascript functions: 1 2 I would like to put them in external ".js" files 1 2 What is the correct syntax to call these functions? Code like this I hope it will help you....
thanks 这篇关于如何使用外部“.js”档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ b $ 1
pre $
<形式>
< select name =usersonChange =showUser(this.value)>
< option value =1> Tom< / option>
< option value =2>鲍勃< / option>
< option value =3> Joe< / option>
< / select>
< / form>
< html>
< head>
< script type =text / javascriptsrc =path / to / script.js>< / script>
<! - 其他脚本和外部CSS都包含在这里 - >
< / head>
< body>
< form>
< select name =usersonChange =showUser(this.value)>
< option value =1> Tom< / option>
< option value =2>鲍勃< / option>
< option value =3> Joe< / option>
< / select>
< / form>
< / body>
< / html>
谢谢showCountry()
showUser()
<a href="javascript:showCountry('countryCode')">countryCode</a>
<form>
<select name="users" onChange="showUser(this.value)">
<option value="1">Tom</option>
<option value="2">Bob</option>
<option value="3">Joe</option>
</select>
</form>
<html>
<head>
<script type="text/javascript" src="path/to/script.js"></script>
<!--other script and also external css included over here-->
</head>
<body>
<form>
<select name="users" onChange="showUser(this.value)">
<option value="1">Tom</option>
<option value="2">Bob</option>
<option value="3">Joe</option>
</select>
</form>
</body>
</html>