Learning JQuery: event binding entry & control function & style

1, basic grammar learning:

    1, event binding

    2, the import function

    3, style control

<!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> 
        // to b1 button to add a click event 

        // JS: After loading 
        // the window.onload = function () { 
        //       // 1, to obtain b1 button 
        //       $ ( "# b1") the Click (function (. ) { 
        //          Alert ( "ABC"); 
        //      }) 
        // } 

        / * 
            entry functions: window.onload and $ difference (function) of 
                * window.onload defined only once, if multiple definitions, will be behind the the front overwrite 
                * $ (function) can define multiple 
        * / 
        // $ (function () { 
        //      Alert ( ". 1"); 
        // }); 
        // $ (function () { 
        //      Alert ( "2"); 
        // }); 
        //jquery entry function (code for this function is performed after the document has finished loading dom) 
        $ ( function () {
             // 1, b1 button to get 
            // event binding 
            $ ( " # b1 " ) .click ( function () { 
                Alert ( " ABC " ); 
            }) 
        }); 

        $ ( function () {
             // first writing 
            // $ ( "# DIV1") CSS ( "background-Color", "Red");. 
            // The second written 
            $ ( " # 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>

 

Guess you like

Origin www.cnblogs.com/flypig666/p/11607396.html
Recommended