jquery $("<li />")
Wha开发者_StackOverflow社区t does:
$("<li />")
mean in jquery?
it's like document.createElement('li');
Create's a new (but empty) li
element, similar to document.createElement("li");
.
Try doing this:
alert($("<li />")[0]);
Essentially, alone it does not do much. To add it to an existing element you could do something like:
$("<li />").appendTo("body");
$("<li />").appendTo("#elementId");
It will create a li element, similar to https://developer.mozilla.org/en/DOM/document.createElement
Creates DOM elements (in this case LI) on the fly from the provided string of raw HTML.
http://api.jquery.com/jQuery/#jQuery2
By itself nothing but if you add
$('<li />').appendTo('body');
It will create an li at the end of the body element of your HTML
精彩评论