Solved

jquery insert item into bottom of a div

Posted on 2009-05-15
1
3,091 Views
Last Modified: 2012-06-21
I have a document like this

<div id="menu"></div>

<div class="itemplate"></div>  //This is what I am cloning and moving

I want to put items into the menu, so
<div id="menu">
   <div id="item_1"></div>
   <div id="item_2"></div>
</div>


I want to insert an item into the last position inside the menu.  The menu could start off blank.

I can successfully keep inserting items after somethign, but that is not what I want to do.
var newlyInsertedDiv = $("#template").clone().insertAfter($(".menu"));
newlyInsertedDiv.attr("id", "item_" + counter);


How do I make it so I can insert my cloned div into the last position inside menu?
0
Comment
Question by:jackjohnson44
1 Comment
 
LVL 12

Accepted Solution

by:
alien109 earned 500 total points
ID: 24398971
var newlyInsertedDiv = $("#template").clone();
$("#menu").append(newlyInsertedDiv);
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now