Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9147749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:04:14+00:00 2026-06-17T11:04:14+00:00

I have a styled element with the class ‘item’ that is hidden. Initially the

  • 0

I have a styled element with the class ‘item’ that is hidden. Initially the page will only have one element with this class. I am simply using this hidden element as a model, that I can grab with jquery and insert it into a list every time the ‘add item’ button is clicked, with the correct item name in the inner text.

What I am trying to do is clone this hidden ‘item’ element and insert it right after where the last item element is located on the webpage. Show it, and change the inner text to whatever I need.

My current implementation does not clone / insert items as expected, though I believe it should, I am probably missing something.

My Markup

<div class="item" style="border:1px solid blue; padding:7px; display:none;">hello</div>

add item

My JavaScript

$(".addItem").click(function(){

   //clone hidden item element blueprint
   $('.item').eq(0).clone().insertAfter('.item:last-child');


   //Change inner text of element
   $('.item:last-child').text("apples").show();
});

JSFiddle

http://jsfiddle.net/XPVAs/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:04:15+00:00Added an answer on June 17, 2026 at 11:04 am

    Suppose you need :last selector, instead of :last-child:

    $(".addItem").click(function(){
    
        //clone hidden item element blueprint
        $('.item').eq(0).clone().insertAfter('.item:last');
    
    
        //Change inner text of element
        $('.item:last').text("apples").show();
    });
    

    And here is a demo: http://jsfiddle.net/XPVAs/3/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html img that is being styled by a CSS class. I
I have two elements in a div element. One is styled to float left
I want to have a element that displays in the multiple selection display style
Thanks everyone for taking the time to read this. I have styled my navigation
I have created styled a ListBox in WPF so that it is rendered as
I have this: <ol> <li class=letter> <li class=letter> <li> <li> <li> <li> <li> <li>
I have the following script: $(.Text).contents().each(function () { $(this).replaceWith($(this).text() .replace(/\[([^\]]*)\]/g, '<span class=IT_Symbol style=display:inline;border: 1px
I have this elements: <div class=ELEMENT_LISTY style=> <div class=TITLE id=174>string</div> <div class=BUTTONY> <div class=POGLAD></div>
This is driving me mad , I have a code that works perfect with
If I have a style definition in SCSS that looks like this: #someid {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.