I want to add one more li
at last but using JavaScript/jQuery
for example i want to add this li
at last <li><a href="#header" >Back to top</a></li>
<ul id="nav">
<li><a href="#nowhere" >Lorem</a></li>
<li><a href="#nowhere" >Aliquam</a></li>
<li><a href="#nowhere" >Morbi</a></li>
<li><a href="#nowhere" >Praesent</a></li>
<li><a href="#nowhere" >Pellentesque</a></li>
Here i want to add one more li using javascript
</ul>
I want to add one more li
at last but using JavaScript/jQuery
for example i want to add this li
at last <li><a href="#header" >Back to top</a></li>
<ul id="nav">
<li><a href="#nowhere" >Lorem</a></li>
<li><a href="#nowhere" >Aliquam</a></li>
<li><a href="#nowhere" >Morbi</a></li>
<li><a href="#nowhere" >Praesent</a></li>
<li><a href="#nowhere" >Pellentesque</a></li>
Here i want to add one more li using javascript
</ul>
Share
Improve this question
asked May 27, 2010 at 5:16
Jitendra VyasJitendra Vyas
153k240 gold badges587 silver badges868 bronze badges
1
- possible duplicate of jQuery: how to add <li> in an existing <ul>? – Jørn Schou-Rode Commented May 27, 2010 at 22:54
2 Answers
Reset to default 4$(document).ready( function(){
$('ul#nav').append('<li><a href="#header">Back to top</a></li>');
}
Use the append function.
$("#nav").append('<li><a href="#header">Back to top</a></li>');