zoukankan      html  css  js  c++  java
  • jQuery1——基本概念

    jQuery与原生js入口函数的区别:
    1.原生js和Jquery入口函数的加载模式不同:
    原生js会等到DOM元素加载完毕,并且图片加载完毕才会执行;
     Jquery会等到DOM元素加载完毕,但不会等到图片加载完毕就会执行。
     
    2.原生的js如果写了多个入口函数,后面编写的会覆盖前面编写的;
    Jquety如果写了多个入口函数,后面编写的不会覆盖前面编写的。
     
    jQuery入口函数的其他写法:
    //1.第一种写法
    $(document).ready(function () {
        //alert("hello ghl");
    });
    
    //2.第二种写法
    jQuery(document).ready(function () {
        //alert("hello ghl");
    });
    
    //3.第三种写法(最推荐)
    $(function () {
        alert("hello ghl");
    });
    
    //4.第四种写法
    jQuery(function () {
        alert("hello ghl");
    });
    

    jQuery冲突问题:

    //1.释放$的使用权
    //注意点:释放操作必须在编写其他jQuery代码之前
    //        释放之后不能再使用$符号,改为使用jQuery
    jQuery.noConflict();
    jQuery(function () {
        alert("hello ghl");
    });
    
    //2.自定义一个访问符号
    var nj=jQuery.noConflict();
    nj(function () {
        alert("hello ghl");
    })
    

      

  • 相关阅读:
    Codevs堆练习
    codevs 3110 二叉堆练习3
    浅谈堆
    codevs 2924 数独挑战
    搜索技巧——持续更新
    2144 砝码称重 2
    codevs 2928 你缺什么
    codevs 2594 解药还是毒药
    codevs 2147 数星星
    判断素数
  • 原文地址:https://www.cnblogs.com/ghlz/p/13299510.html
Copyright © 2011-2022 走看看