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 IO流之详细总结
    位运算了解与复习多线程
    java 常见面试题总结(一)
    复习集合框架
    【面试题】java中高以上必会技能
    python-项目流程分析及优化查询方法
    python-day97--django-ModelForm
    python-day97--git协同开发
    python-day96--git版本控制
    python-day91--同源策略与Jsonp
  • 原文地址:https://www.cnblogs.com/pangblog/p/3331452.html
Copyright © 2011-2022 走看看