What is the <li / "> tag for ..?
What is a tag <li/>
for.?
Can anyone point / find / share some related documentation ??
I found the code in this answer on "thecodeparadox"
I tried to find some documentation related to this in vain.
source to share
jQuery provides an alternative to the traditional DOM creation element.
$("<li/>"); //create li element
If you want to change an element or associate events with it, you can do the following:
$("<li/>", {
click: function(){}, //allows you to bind events
id: "test", // can be set html attribute
addClass: "clickable" //allows you to bind jquery methods
});
The documentation can be found here .
source to share
HTML provides tags for building ordered <ol>
("numbered") and unordered <ul>
("bulleted") lists.
Each item in such a list is identified by a tag <li>
.
<ul>
<li>First!</li>
<li>Second Base</li>
<li>Three Strikes and you are Out</li>
</ul>
(unfortunately, you often see the end tag </li>
omitted) The notation <TAG/>
is shorthand for empty tag (that is, equivalent <TAG></TAG>
).
It is not enough to be used for an empty list item, other than as a placeholder to be extended later by javascript.
source to share
The <li/>
jQuery tag is for creating tags. It's shorthand for <li></li>
, in the jQuery documentation :
If the parameter has a single tag (with an optional closing tag or quick close) -
$( "<img />" )
or$( "<img>" )
,$( "<a></a>" )
or$( "<a>" )
- jQuery creates the element using a built-in JavaScript function.createElement()
.
Basic sample:
$('<li/>').text('Hello World 1').appendTo('ul');
$('<li></li>').text('Hello World 2').appendTo('ul');
$('<li>').text('Hello World 3').appendTo('ul');
See jsFiddle Demo .
source to share