How to add a list item to an existing unordered list

I have code that looks like this: <div id=”header”> <ul class=”tabs”> <li><a href=”/user/view”><span class=”tab”>Profile</span></a></li> <li><a href=”/user/edit”><span class=”tab”>Edit</span></a></li> </ul> </div> I’d like to use jQuery to add the following to the list: <li><a href=”/user/messages”><span class=”tab”>Message Center</span></a></li> I tried this: $(“#content ul li:last”).append(“<li><a href=”/user/messages”><span class=”tab”>Message Center</span></a></li>”); But that adds the new li inside the last li (just … Read more

Creating a div element in jQuery [duplicate]

This question already has answers here: jQuery document.createElement equivalent? (14 answers) Closed 4 years ago. How do I create a div element in jQuery? 2 24 As of jQuery 1.4 you can pass attributes to a self-closed element like so: jQuery(‘<div>’, { id: ‘some-id’, class: ‘some-class some-other-class’, title: ‘now this div has a title!’ }).appendTo(‘#mySelector’); … Read more