?
Solved

jquery insert item into bottom of a div

Posted on 2009-05-15
1
Medium Priority
?
3,098 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

771 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