zoukankan      html  css  js  c++  java
  • js jquery 页面加载初始化方法

    出处:https://www.cnblogs.com/ooo0/p/6123465.html

    一、js 页面加载初始化方法

    // 1.在body里面写初始化方法.
    <body onload='init()'>
    </body>
    <script type="text/javascript">
        function init(){
             // 初始化内容       
        }
    </script>

    // 2.window.onload=function(){}
    <script type="text/javascript">
        window.onload=function(){
            // 初始化内容
        }
    </script>

    // 3.写初始化方法,页面顺序执行到初始化方法时初始化
    <script type="text/javascript">
        function init() {
            // 初始化内容
        };
        init();
    </script>

    二、jquery 页面加载初始化方法


    // 1.$(function(){})
    <script type="text/javascript">
        $(function() {// 初始化内容
        });  
    </script>


    // 2.$(document).ready(function(){})
    <script type="text/javascript">
        $(document).ready(function(){  
            // 初始化内容
        });  
    </script>

    //
    ready()
    函数有以下三种等价的形式
    function handler(){
        //这里是需要执行的代码
    }
    // 形式一
    $(document).ready( handler );
    // 形式二
    $( ).ready( handler ); // 不推荐该形式
    // 形式三
    $( handler );

     
    // 3.jQuery(function($){})
    <script type="text/javascript">
        jQuery(function($){  
            // 初始化内容
        });  
    </script>

  • 相关阅读:
    Sprinig.net 双向绑定 Bidirectional data binding and data model management 和 UpdatePanel
    Memcached是什么
    Spring.net 网络示例 codeproject
    jquery.modalbox.show 插件
    UVA 639 Don't Get Rooked
    UVA 539 The Settlers of Catan
    UVA 301 Transportation
    UVA 331 Mapping the Swaps
    UVA 216 Getting in Line
    UVA 10344 23 out of 5
  • 原文地址:https://www.cnblogs.com/haimeimei/p/13343886.html
Copyright © 2011-2022 走看看