Reputation: 18328
What does:
$("<li />")
mean in jquery?
Upvotes: 0
Views: 227
Reputation: 15877
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");
Upvotes: 4
Reputation: 17638
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
Upvotes: 1
Reputation: 31260
Creates DOM elements (in this case LI) on the fly from the provided string of raw HTML.
http://api.jquery.com/jQuery/#jQuery2
Upvotes: 1
Reputation: 21388
It will create a li element, similar to https://developer.mozilla.org/en/DOM/document.createElement
Upvotes: 2