zoukankan      html  css  js  c++  java
  • jQuery最佳实践(不断更新中...)

    1. 处理cdn失效

    <script type="text/javascript" src="http://xxx.com/jquery.min.js "></script>
    <script type="text/javascript">
    if(typeof jQuery == 'undefined'){
        document.write("<script type='text/javascript' src='js/jquery.min.js'></script>");
    }
    </script>

    2. 所有的事件绑定都使用如下所示的“代理”模式

        $(document).on('click','#qiehuan',function(){
            var isFs = $(this).attr("datas");
            $.cookie("isFs",isFs,{ expires: 7 }); 
        });

    3. 事件绑定放在 $(document).ready() 中进行:

    $(document).ready(function() {
        $(document).on('blur', '#no', function(){
            ems.register.validate_no();
        });
        // ...
    });

    4. 使用命名空间函数 $.namespace("xxx");

    具体参见:http://www.cnblogs.com/digdeep/p/4175969.html

  • 相关阅读:
    Hashmap实现原理
    策略模式
    Google Drive ubuntu
    numix Docky
    Google Drive 和 Dropbox 同步同一个文件夹目录
    sublime text 2
    matlab cell
    liteide
    taglist and nerdtree
    codeblocks
  • 原文地址:https://www.cnblogs.com/digdeep/p/4454518.html
Copyright © 2011-2022 走看看