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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:16:05+00:00 2026-06-13T08:16:05+00:00

My experience level – I am making a custom slider and this is my

  • 0

My experience level –
I am making a custom slider and this is my first experience with jQuery, but I think I have a pretty good handle as to what html,css and jquery do together but, still have my noob-ness going on.

My Problem – I have 17 div’s marked up as such, and I would like to remove the img tag:

      <div class="slide" id="zero">
        <h2>April 1, 2011</h2>
        <img src="img/1_april12011.png"/><p>Lorem Ipsum</p>
      </div>
      <div class="slide" id="one">
        <h2>April 2011</h2>
        <img src="img/2_april2011.png"/> <p>Lorem Ipsum</p>
      </div>
      <div class="slide" id="two">
        <h2>August 2011</h2>
        <img src="img/3_aug2011.png"/><p>Lorem Ipsum</p>
      </div>

I can do this pretty easily by using .detach() and the following jQuery:

 $('.slide').delegate('click', function(){ 
      if(imageToAttach == null){
        attachLocation = $(this).find('id');
        imageToAttach = $(this).find('img').detach();
        console.log
      }else{
        $(imageToAttach).appendTo(attachLocation);
        console.log('trying to append ' + imageToAttach + ' to ' + attachLocation);
        attachLocation = $(this).find('id');
        imageToAttach = $(this).find('img').detach();
        console.log('detached ' + imageToAttach);
      }});

I am using the var = imageToAttach and attachLocation to keep track of what image was removed and where it was removed from so I can append it to that specific div again when I want to (when another image is clicked or the left and right control are clicked) so if I can get this — http://jsfiddle.net/lorenzo_vm/nbF8d/3/ — jsfiddle to work, then I believe I can do what I want.

few hours of research and fiddling later

I think I figured out I want to do, I am going to use .hide() and .show(), but I am still curious as to what is going on in the above mentioned fiddle…that is, how do I get the img to become re-inserted to the same div they were from when I click on another div…and if you, kind stackoverflow user, would not mind, could you also inform me of an easier way to assign the divs to an array of some sort instead of using id=”zero” id=”one” etc.

something like this?

var slides = $('.slide');
var numberOfSlides = slides.length;
var slideArray[] = null; 

would I just use a for loop to assign the index of slides.length to each spot in an array?

for( var i=0;i<=numberOfSlides;i++){
   slideArray[i] = ?;
}

Or is the var slides an array? I am little confused.

THANKS SO MUCH!

  • Michael
  • 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-13T08:16:07+00:00Added an answer on June 13, 2026 at 8:16 am

    Here. I updated your fiddle to do what I think is what you’re looking for – mostly. Not too sure though since this behavior is odd to me and I don’t know exactly why one would want to do this…

    http://jsfiddle.net/nbF8d/12/

    here is the relevant code, which can be condensed to this:

    $(document).ready(function(){
        var imageToAttach;
        var attachLocation;
    
        $('.slide').on('click', function(){ 
          if(imageToAttach != null){
            $(imageToAttach).appendTo(attachLocation);
          }
    
          attachLocation = $(this);
          imageToAttach = $(this).find('img').detach();
       });
    });
    ​
    

    Essentially, you were trying to find an element “id” when you should just store the reference to the element clicked.

    attachLocation = $(this);
    

    That way appendTo has an element instead of just the value of an id (assuming you fetched the actual id by using $(this).attr('id'))

    Also your example did not declare the vars or place the listener in the ready call.

    Also notice I switched to .on instead of .delegate – see this: “As of jQuery 1.7, .delegate() has been superseded by the .on() method.”

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

Sidebar

Related Questions

I don't have much experience in this yet but the high level question that
I have no experience with low level programing and I need this piece of
Debugging experience http://www.dmhermitage.org/wtfborders.png This is making me want to kill myself. I have some
I'm learning C, but i have a long experience with higher level programming languages
I have experience in higher level languages, but I'm new to C. I've been
I do not have a ton of PHP experience, but whenever I have been
Experience level: newbie. The backbone.js Todos demo uses localStorage. This question is about how
I have pretty much 0 experience in developing websites. I was wondering if anyone
Does anybody have any experience with Magento module level cron jobs across multiple instances
Let's say I have this code: <?php $aLevel[] = 98; function experience($L) { $a=0;

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.