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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:12:54+00:00 2026-05-26T07:12:54+00:00

To better explain what I need I uploaded an example here . I have

  • 0

To better explain what I need I uploaded an example here.

I have 3 divs, and clicking on either one of them will have the same image menu appear on the right. What I have now is: click on the first div, then go to the menu, choose an image and use .prepend() to show that image on the clicked div. But if I get the image menu appearing when clicking the second or third div and choose a color, this is still displayed on the first div.

A simplified HTML is something like this:

<div id="tela1"><img src="img/blank.jpg" /></div>
<div id="title_tela1"></div>
<div id="tela2"><img src="img/blank.jpg" /></div>
<div id="title_tela2"></div>

<div id="tela1_options">
    <div class="image_carousel1>
        Content goes here...
    </div>
</div>
<div id="tela2_options">
    <div class="image_carousel2>
        Content goes here...
    </div>
</div>

And the JS:

$('.carousel_image1 img').click(function () {
    var imageName = $(this).attr('alt');
    var chopped = imageName.split('.');
    $('#title_tela1').empty();
    $('#title_tela1')
        .prepend(chopped[0]);
    $img = $(this);
    $('#tela1 img').attr('src', $img.attr('src'));
})

I tried using the selector ('#tela1_options .carousel_image1 img') for each of the three divs, but still when I choose an image is displayed only on the first div.

Can someone take a look and help me figure this out?

  • 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-05-26T07:12:55+00:00Added an answer on May 26, 2026 at 7:12 am

    Inside of you click function for the carousel, you have “#tela1” hard coded. That part needs to be dynamic based on what div was clicked. You will probably want to store the clicked div in a variable that will be used inside of the click function. Here is a sample of what your document.ready function could look like:

    $(function(){
        var clickedDiv = null;
    
        $(".tela").click(function(){
            clickedDiv = $(this);
        });
    
        $('.carousel_image1 img').click(function () {
            var $img = $(this),
                imageName = $img.attr('alt'),
                chopped = imageName.split('.');
    
            clickedDiv.next().text(chopped[0]);
            clickedDiv.find('img').attr('src', $img.attr('src'));
        });
    });
    

    In order for that to work, you will need to add the class=”tela” to the divs.

    <div id="tela1" class="tela"><img src="img/blank.jpg" /></div>
    <div id="title_tela1"></div>
    <div id="tela2" class="tela"><img src="img/blank.jpg" /></div>
    <div id="title_tela2"></div>
    

    Here is a working example on jsFiddle: http://jsfiddle.net/jY4qa/2/
    I only set up the images in the first carousel to show up. But if you click on one of the blank divs and then an image it sets it correctly. I also had to update the image carousel selector in the JS for my example.

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

Sidebar

Related Questions

World's most convuluted title I know, an example should explain it better. I have
To better explain what I'm trying to achieve, here's a simple example: Scenario 1
ok, i will explain first what i have, and what i need as result.
To help better explain my Question, here is what i have: I am using
Note I have completely re-written my original post to better explain the issue I
I have Bitnami Rails stack installed on my Mac. To better explain my problem
I'm having troubles releasing objects.. To explain it better I have included my code
Let me better explain this title. What I am looking for is an image
I guess I don't give title nicely, anyways, I can explain it better here:
Well, it will be a bit hard to explain what i need to do

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.