• jquery第一期:运行第一个jquery


    首先下载js文件,网址jquery.com去下载,可以下载1.10版的


    首先打开editplus进行编辑,添加js文件:


    编写代码:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script type="text/javascript" src="js/jquery-1.10.1.js"></script>
    <script type="text/javascript">
       $(document).ready(function()
       {
       alert("hello jquery");
       });
    </script>
    </head>
    <body>
    
    </body>
    </html>
    <script type="text/javascript" src="js/jquery-1.10.1.js"></script>

    首先把通过src属性添加js文件


    $(document).ready

    当文档完全加载完执行的函数


    运行结果:



    我们完全可以简化我们的代码,

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script type="text/javascript" src="js/jquery-1.10.1.js"></script>
    <script type="text/javascript">
       $(function()
       {
       alert("hello jquery");
       });
    </script>
    </head>
    <body>
    
    </body>
    </html>

    也就是说document.ready是可以省略的。




  • 相关阅读:
    python笔记
    React+router和react+redux使用过程的记录
    jQuery源码分析随笔
    安装nodejs+ionic+cordova环境心得
    win10系统Nodejs安装包总是失败原因
    silverlight中dialogresult和close
    安卓HTTP访问的两种方式
    安卓Activity跳转的几种方式
    Android开发Content Provider
    web.xml中filter的用法
  • 原文地址:https://www.cnblogs.com/pangblog/p/3331452.html
Copyright © 2020-2023  润新知