javascript - I would like to ask, after creating a new node in jquery, insert it and then add css style to this node, can it be written in one sentence?
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-06-26 10:53:28
0
1
618
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
    <title>s</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }

        
    </style>
</head>
<body>
    <p class="main">
        <p>111</p>
        <p>222</p>
        <p>333</p>
        <p>444</p>
        <p>555</p>
    </p>

    <script>
    $(document).ready(function(){
        var t = $("<p>hello world!</p>");
        $(".main").append(t);
        $(".main p:last-child").css("color","red");
    })
    </script>
</body>
</html>

Excuse me, Master, can the jquery here be written in one sentence? . .

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
三叔
  $("<p>hello world!</p>").appendTo(".main").css("color","red");
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template