Chris Muench
Chris Muench

Reputation: 18328

jquery $("<li />")

What does:

$("<li />")

mean in jquery?

Upvotes: 0

Views: 227

Answers (5)

Shaz
Shaz

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

mcgrailm
mcgrailm

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

amit_g
amit_g

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

Robert
Robert

Reputation: 21388

It will create a li element, similar to https://developer.mozilla.org/en/DOM/document.createElement

Upvotes: 2

Teneff
Teneff

Reputation: 32158

it's like document.createElement('li');

Upvotes: 6

Related Questions