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

  • Home
  • SEARCH
  • 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 3390652
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:42:59+00:00 2026-05-18T03:42:59+00:00

I am trying to use javascript/jquery. I have got below HTML where I want

  • 0

I am trying to use javascript/jquery.

I have got below HTML where I want to work on “onclick” event of image link.

<div id="galleryContainer">
    <ul class="galleryThumbnails">
        <li><a href="/99/english/destinations_offers/destinations/asiapacific/india/newdelhi/photo.aspx?item=media_616165_ID0EV&amp;menu=image_616165#mplayer_616165">
            <img width="70" height="56" src="http://corp.com/99/english/images/thumb_616143_tcm481-616166.jpg"
                class="mpMenuItemSelected" id="thumb_616165_ID0EV" title="New Delhi Zoo" alt="New Delhi Zoo"></a>
        </li>
        <li><a href="/99/english/destinations_offers/destinations/asiapacific/india/newdelhi/photo.aspx?item=media_616165_ID0E3&amp;menu=image_616165#mplayer_616165">
            <img width="70" height="56" src="http://corp.com/99/english/images/thumb_616146_tcm481-616168.jpg"
                class="mpMenuItemOff" id="thumb_616165_ID0E3" title="New Delhi Zoo" alt="New Delhi Zoo"></a>
        </li>
        <li><a href="/99/english/destinations_offers/destinations/asiapacific/india/newdelhi/photo.aspx?item=media_616165_ID0EDB&amp;menu=image_616165#mplayer_616165">
            <img width="70" height="56" src="http://corp.com/99/english/images/redfort_tcm481-616158.jpg"
                class="mpMenuItemOff" id="thumb_616165_ID0EDB" title="New Delhi RedFort" alt="New Delhi RedFort"></a>
        </li>
    </ul>       
        <div id="media_616165_ID0EV" class="galleryImage">
        <img width="390" height="312" alt="New Delhi Zoo" title="New Delhi Zoo" src="http://corp.com/99/english/images/10894_tcm481-616143.jpg"></div>

    <div style="display: none;" id="media_616165_ID0E3" class="galleryImage">
        <img width="390" height="312" alt="New Delhi Zoo" title="New Delhi Zoo" src="http://corp.com/99/english/images/deer_tcm481-616146.jpg"></div>

    <div style="display: none;" id="media_616165_ID0EDB" class="galleryImage">
        <img width="390" height="312" alt="New Delhi RedFort" title="New Delhi RedFort" src="http://corp.com/99/english/images/redfort_tcm481-616157.jpg"></div>        
</div>  

In above HTML, I have got thumbnail images ( please see the UL) for example

<img width="70" height="56" src="http://corp.com/99/english/images/thumb_616143_tcm481-616166.jpg"
                class="mpMenuItemSelected" id="thumb_616165_ID0EV" title="New Delhi Zoo" alt="New Delhi Zoo">

Now I have got separate galleryImage div section for every thumbnail Image, which will show on the click on thumbnail image. For example to the above thumbnail there is

    <div id="media_616165_ID0EV" class="galleryImage">
<img width="390" height="312" alt="New Delhi Zoo" title="New Delhi Zoo" src="http://corp.com/99/english/images/10894_tcm481-616143.jpg"></div>

I want to hide and show the images according to the thumbnail is clicked.

EDIT:

I am having tab functionality as a link when first time the page is rendered the below @Rahul code works perfectly, however after navigating the any tab and again coming back it stops working the reason is that after coming back on same tab, my previous jquery code adds and extra div with same contents, below jquery get confused as my page now will be having same code twice. Please see the example code when first time page is rendered.

<div class="tabs-container" id="tab-container">
top above html is rendered here
</div>

Now after navigating to other tab and coming back to same tab, now html on page is as below, the above mentioned code remain there in page with style=”display: none;” an extra div is added to play the tab functionality:

<div class="tabs-container" id="tab-container" style="display: none;">
top above html is rendered here
</div>
<div id="divContenttab5" style="display: block;" class="dynDiv">
  <div class="tabs-container" id="tab-container">
      top above html is rendered here
</div>
</div>

Now the below Jquery stops working as there are same two type of htmls.

Please suggest!

Thanks.

Best Regards,
MKS

  • 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-18T03:43:00+00:00Added an answer on May 18, 2026 at 3:43 am

    I resolved my issue with CSS class toggling, I changed the code given by @Rahul, please have a look and suggest for any changes.

    $("#galleryContainer ul.galleryThumbnails li img").click(function () {
        var idArr = this.id.split('_');
        var divID = "media_" + idArr[1] + "_" + idArr[2];
        $("#galleryContainer ul.galleryThumbnails li img").each(function () {
            if ($(this).is('.mpMenuItemSelected')) {
                $(this).removeClass('mpMenuItemSelected');
                $(this).addClass('mpMenuItemOff');
            }
        });
        $("div.galleryImage").hide();
        $("#" + divID).show();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big red button and I'm trying to use javascript to perform
I'm trying to use the jqueryui dialog ( http://docs.jquery.com/UI/Dialog ) within my html page.
I'm trying to use jquery to create a tab effect for several div contents.
I am trying to replace the JavaScript onclick event handler in ASP.NET that is
I'm trying to use jQuery's $(this) inside of Fancybox's onComplete event, but I'm running
I am trying to use jquery to do an animated scroll from one div
I'm trying to use CSS ( under @media print ) and JavaScript to print
I'm trying to develop an application that will use getImageData in javascript in Firefox
I'm trying to create a small Javascript framework that I can use in my
While trying to use LINQ to SQL I encountered several problems. I have table

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.