开发者

jquery $("<li />")

开发者 https://www.devze.com 2023-02-24 09:53 出处:网络
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\");.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消