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 868719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:11:13+00:00 2026-05-15T10:11:13+00:00

hope can help, trying out Jquery clone which seems to work, but I get

  • 0

hope can help, trying out Jquery clone which seems to work, but I get “multiple” clones not single clones on “repressing” the button.

e.g.: I want to clone this :

echo '<select class="hello">';
    foreach ($pageposts as $post):
    echo '<option>'.$post->post_title.'</option>';
    endforeach;
    echo '</select>';

on click of this

echo '<input type="button" id="rp" value="add">';

Yes from WordPress and Yes the “hello” class is from the JQuery pages

My JQuery function is:

$j=jQuery.noConflict();
$j(document).ready(function() {
$j('#rp').click(function(){ 
$j('.hello').clone().appendTo('#goodbye');
});
});

So my “overall code snippit” looks like this:

echo '<select class="hello">';
foreach ($pageposts as $post):
echo '<option>'.$post->post_title.'</option>';
endforeach;
echo '</select>';
echo '<div id="goodbye"></div>';
echo '<input type="button" id="rp" value="add">';

I clone “once” on the first press, but then it goes in multiples i.e.:

1 click gives 1 clone plus 1 original – what I want

2 clicks gives 3 clones plus 1 original – not what I want I want 1 original plus 2

3 clicks gives 7 clones plus 1 original – not what I want I want 1 original plus 3
etc.

Suggestions please. Thanks

  • 1 1 Answer
  • 3 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-05-15T10:11:14+00:00Added an answer on May 15, 2026 at 10:11 am

    It’s because your selector is looking for a class:

    $j('.hello')
    

    Everytime you clone and append this to another element you’re adding yet another .hello element, therefore your cloning every single .hello element it can find.

    Perhaps you should remove the class name when it’s been cloned:

    $j('.hello').clone().removeClass('hello').appendTo('#goodbye');
    

    Or perhaps even change it:

    $j('.hello').clone().removeClass('hello').addClass('cloned_hello').appendTo('#goodbye');
    

    You might want to add a different class so your CSS will still work, but ultimately this is why you’re getting multiple cloned items.

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

Sidebar

Related Questions

hope anyone can help me. I'm trying to figure out what pointer to an
the following codes are what i'm trying to figure out.Hope you guys can help
I have been trying to figure this out for days. Hope someone can help.
I hope someone can help, I am trying to enable enable ASP.Net Impersonation under
I hope somebody can help me. I've been trying to write a custom html
I hope someone can help with the following. I'm trying to create a user-specific
Hope someone can help i cant seem to get my head around this, i
Hope someone can help me out with this problem I am having. I just
I hope you can help, I've tried for hours to understand mod rewrite but
I hope someone can help me as I've already spent several hours trying to

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.