zoukankan      html  css  js  c++  java
  • 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是可以省略的。




  • 相关阅读:
    【转】Java学习---HashMap的工作原理
    【转】Java学习---集合框架那些事
    Linux学习---linux下的彩蛋和各种有趣的命令
    【转】VMware虚拟机三种网络模式超详解
    沃顿商学院的MBA课程
    本杰明-富兰克林的13节制
    美学需要读的书
    芒格推荐书单
    回声消除(AEC)原理
    adc0和adc1
  • 原文地址:https://www.cnblogs.com/pangblog/p/3331452.html
Copyright © 2011-2022 走看看