因为我目前知道$("这里面要写选择器")
$("<p></p>").text("Text.")
但是上面这段代码双引号里写了
<p></p>
然后我就迷糊了,因为看下面的源码的话,是创建了一个p标签,不是选择了p标签,所以我想知道$("
").text("Text.") 这个是什么下面是源码:
<script>
function appendText()
{
var txt1="<p>Text.</p>"; // Create text with HTML
var txt2=$("<p></p>").text("Text."); // Create text with jQuery
var txt3=document.createElement("p");
txt3.innerHTML="Text."; // Create text with DOM
$("body").append(txt1,txt2,txt3); // Append new elements
}
</script>
</head>
<body>
<p>This is a paragraph.</p>
<button onclick="appendText()">Append text</button>
就是在这看到的 http://www.runoob.com/try/try.php?filename=tryjquery_html_append2
This is a paragraph.
Append text
Text.
Text.
Text.
其他的都可以理解,就是第二个Text. 理解不了是怎么创建出来的