如何将JavaScript文件链接到HTML文件? [英] How do I link a JavaScript file to a HTML file?

查看:86
本文介绍了如何将JavaScript文件链接到HTML文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



其次,如何在JavaScript文件中使用jQuery?

$ b $首先,您需要从 http://jquery.com/ 下载JQuery库。

/ a>然后
在您的html头标记内以下面的方式加载jquery库

然后您可以通过编写jquery代码来测试jquery是否工作jquery加载脚本

 <!DOCTYPE html> 
< html xmlns =http://www.w3.org/1999/xhtml>
< head>
< script type =text / javascriptsrc =jquery-1.8.3.js>< / script>
< script type =text / javascript>
$(function(){
alert(My First Jquery Test);
});
< / script>
< / head>
< body>< / body>
< / html>

如果您想单独使用jquery脚本文件,您必须以这种方式定义外部.js文件jquery库加载。

 < script type =text / javascriptsrc =jquery-1.8.3.js >< /脚本> 
< script src =js / YourExternalJQueryScripts.js>< / script>


How do you properly link a JavaScript file to a HTML document?

Secondly, how do you use jQuery within a JavaScript file?

解决方案

First you need to download JQuery library from http://jquery.com/ then load the jquery library the following way within your html head tags

then you can test whether the jquery is working by coding your jquery code after the jquery loading script

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="jquery-1.8.3.js"></script>
<script type="text/javascript">
   $(function(){
      alert("My First Jquery Test");
   });
</script>
</head>
<body></body>
</html>

If you want to use your jquery scripts file seperately you must define the external .js file this way after the jquery library loading.

<script type="text/javascript" src="jquery-1.8.3.js"></script>
<script src="js/YourExternalJQueryScripts.js"></script>

这篇关于如何将JavaScript文件链接到HTML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆