zoukankan      html  css  js  c++  java
  • JQuery学习:事件绑定&入口函数&样式控制

    1、基础语法学习:

        1、事件绑定

        2、入口函数

        3、样式控制

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>事件绑定</title>
        <script src="../js/jquery-3.3.1.js"></script>
    
        <script>
            // 给b1按钮添加单击事件
    
            //js:加载完成后
            // window.onload = function () {
            //      // 1、获取b1按钮
            //      $("#b1").click(function () {
            //         alert("abc");
            //     })
            // }
    
            /*
                入口函数:window.onload  和  $(function)的区别
                    * window.onload 只能定义一次,如果定义多次,后边的会将前边的覆盖掉
                    * $(function) 可以定义多次
            */
            // $(function(){
            //     alert("1");
            // });
            // $(function(){
            //     alert("2");
            // });
            //jquery入口函数(dom文档加载完成之后执行该函数中的代码)
            $(function () {
                // 1、获取b1按钮
                //事件绑定
                $("#b1").click(function () {
                    alert("abc");
                })
            });
    
            $(function(){
                // 第一种写法
                // $("#div1").css("background-color","red");
                // 第二种写法
                $("#div1").css("backgroundColor","pink");
            })
    
    
    
        </script>
    </head>
    
    <body>
    
        <div id="div1">div1...</div>
        <div id="div2">div2...</div>
        <input type="button" id="b1" value="点我">
    
    
    
    </body>
    
    </html>
  • 相关阅读:
    BZOJ5368:[PKUSC2018]真实排名(组合数学)
    【HDU2222】Keywords Search
    KMP算法
    【BZOJ3262】 陌上花开
    【POJ2104】kth num
    【BZOJ1251】序列终结者
    【BZOJ3524】 [Poi2014]Couriers
    【BZOJ2049】 [Sdoi2008]Cave 洞穴勘测
    【BZOJ1468】Tree
    【BZOJ2152】聪聪可可
  • 原文地址:https://www.cnblogs.com/flypig666/p/11607396.html
Copyright © 2011-2022 走看看