Related methods of operation jQuery DOM

<!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">
    <script src="../server/jquery-3.4.1.js"></script>
    <title>Document</title>
</head>

<body>
    <span>A</span>
    <div id="demoID">
        1111 2222 3333
    </div>
    <span>B</span>

    <script>
        / * DOM operations * /
        / * Get: selector [Basic | Level | Screening | father and son ...] * /
        / * Set: Style [css () addClass () removeClass () hasClass () toggleClass ()] * /
        / * Set: Content [text () html ()] * /
        / * Create: * /
        / * Insert * /
        / * [+] A.append (B) B is inserted into the back of the content A == B.appendTo (A) * /
        / * [+] A.prepend (B) B is inserted into the front of the content A == B.prependTo (A) * /

        / * [-] A.insertAfter (B) is inserted into the back of the label A label B * /
        / * [-] A.insertBefore (B) is inserted into the front of the label A label B * /

        // delete remove ()
        // empty: empty ()
        // copy clone (true | false)
        / * Original wording * /
        let oDiv = document.createElement("div");
        oDiv.innerText = "I am a div";
        oDiv.classList.add("box");
        console.log (hissing);

        / * Primeval: appendChild (ele) * /

        // let jq = $("<div></div>");
        // jq.text ( "I am a div");
        // jq.addClass("box");
        // console.log(jq[0]);

        // jQuery wording
        let jq = $("<div class='box'>我的div</div>");
        console.log([0]);
    </script>
</body>

</html>

Guess you like

Origin www.cnblogs.com/huayang1995/p/12121372.html