jQuery property node

In the previous section, we have already talked about how to create nodes and what are text nodes

In this section we will learn how to create attribute nodes

How to create attribute nodes and how we create text nodes It’s the same. Let’s look at a piece of code.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
    <script>
        $(function(){
            var $div = $("<div name='dv'></div>");
            $("body").append($div);
        })
    </script>
</head>
<body>
    
</body>
</html>

Look at the above code. First, we create an attribute node, and then add the node to the body. In the browser, we press F12 to debug, and you can see the following In the source code, <div name='dv'></div>
has been added to the body

Continuing Learning
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script> <script> $(function(){ var $div = $("<div name='dv'></div>"); $("body").append($div); }) </script> </head> <body> </body> </html>
submitReset Code