zoukankan      html  css  js  c++  java
  • (三)初识jQuery

    进入jQuery官网:http://jquery.com/

    点击Download jQuery v3.1.1--->下载最新版本的jQuery版本--->放到你需要引入jQuery的文件中。

    简单示例(引入jQuery文件):

    接下来就可以进行你自己需要的jQuery操作了!!

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        </head>
        <body>
        </body>
        <script src="js/jquery/jquery-1.11.3.min.js"></script>
        <script type="text/javascript">
            $(function(){
                //添加你需要的jQuery操作
            });
        </script>
    </html>

    初步工作完成!

    小示例:

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        </head>
        <body>
        </body>
        <script src="js/jquery/jquery-1.11.3.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                alert("hello world1111!");
            });
            //===等价===
            $(function(){
                alert("hello world2222!");
            });
        </script>
    </html>

     结果:弹出对话框(两次都会执行)

    ===================================================================================

      <script type="text/javascript">
            $(document).ready(function(){
                alert("hello world1111!");
            });
            //===等价===
            $(function(){
                alert("hello world2222!");
            });
        </script>

    关于$(document).ready(function(){//....});和$(function(){//......}); (可编写多个,执行多个)

    $(function(){//......});是$(document).ready(function(){//....});的简写形式,这两种是等价的!

    同时他们和JavaScript中的window.onload();方法相同,但又有区别。

    window.onload方法的使用:(不可以编写多个,一个页面只能有一个、多个时只执行最后一个)

    <script type="text/javascript">
            window.onload = function(){
                alert("111111111");
            };
            window.onload = function(){
                alert("2222222");
            };
            window.onload = function(){
                alert("3333333");
            };
    </script>

     输出为:

  • 相关阅读:
    git常用命令
    国内优秀npm镜像,nvm
    canvas --> getImageData()
    canvas sprite动画 简单封装
    springboot项目中ttf和woff字体图标页面无法显示
    树莓派配置Oracle JDK8
    记一次SqlServer大表查询语句优化和执行计划分析
    linux 查看某个进程和服务内存占用情况命令
    安装MySQL后,需要调整的10个性能配置项
    ARM架构上的Debian10编译timescaledb
  • 原文地址:https://www.cnblogs.com/xiangru0921/p/6520175.html
Copyright © 2011-2022 走看看