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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:54:10+00:00 2026-05-29T03:54:10+00:00

I have 6 images in a line, the first one when the page loads

  • 0

I have 6 images in a line, the first one when the page loads has a class applied to it which using CSS3 applies web transformations. When the other images are hovered over the same class is applied to these, then removed when mouseout. The final thing I need to achieve is that when the other images are hovered over the first one has the class removed, and if no images are hovered over the first one has its class applied to it again.

Here is what I have so far:

$(document).ready(function() {
    $("#imagePackshot li img").hover(function(){
        $(this).addClass('packshot').siblings().removeClass('packshot');
    },
    function () {
        $(this).removeClass('packshot');
    })
    .first().addClass('packshot');
});
  • 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-29T03:54:11+00:00Added an answer on May 29, 2026 at 3:54 am

    You’ll want to check after you remove a class whether there are no other images with the class ‘packshot’, in that case add it to the first one.

     $(document).ready(function() {
            var activeClass = 'packshot', images = $("#gallerySlideshow li img");
            var first = images.first().addClass(activeClass);
            images.hover(function(){
                // remove the class from all images who still have it, most likely only one.
                images.filter("."+activeClass).removeClass(activeClass); 
                // add class to the element that was hovered.
                $(this).addClass(activeClass);
            },
            function () {
                // remove class from the image that was hovered out of
                $(this).removeClass(activeClass);
                // if no other images have the active class, then give it to the first image
                if(!images.filter("."+activeClass).size()){
                   first.addClass(activeClass);
                }
            })
      });
    

    Edit:

    The code is using this html structure, based on the link you posted, which means you can’t use “siblings” to refer to the next images, since the images aren’t siblings in the html tree:

    <ul id="gallerySlideshow">
        <li>
            <a href="page9.html"><img src="thumbnails/thumb9.jpg" width="158" height="236" /></a>
            <ul id="noimg">
                <li>
                    <a href=""><img src="Images/more-like-this.png" /></a>
                </li>
            </ul>
        </li>
    
        <li>
            <a href="page9.html"><img class="box2" src="thumbnails/thumb1.jpg" /></a>
            <ul id="noimg">
                <li>
                    <a href=""><img src="Images/more-like-this.png" /></a>
                </li>
            </ul>
        </li>
    
        <li>
            <a href="page9.html"><img class="box" src="thumbnails/thumb3.jpg"  /></a>
            <ul id="noimg">
                <li>
                    <a href=""><img src="Images/more-like-this.png" /></a>
                </li>
            </ul>
        </li>
    
    
    
        <li>
            <a href="page9.html"><img class="box1" src="thumbnails/thumb4.jpg" /></a>
            <ul id="noimg">
                <li>
                    <a href=""><img src="Images/more-like-this.png" /></a>
                </li>
            </ul>
        </li>
    
        <li>
            <a href="page9.html"><img class="box3" src="thumbnails/thumb5.jpg" /></a>
            <ul id="noimg">
                <li>
                    <a href=""><img src="Images/more-like-this.png" /></a>
                </li>
            </ul>
        </li>
    
        <li>
            <a href="page9.html"><img class="box4" src="thumbnails/thumb6.jpg" /></a>
            <ul id="noimg">
                <li>
                    <a href=""><img src="Images/more-like-this.png" /></a>
                </li>
            </ul>
        </li>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two anchored images on top of each other, separated with a line
I have this in my CSS file: body {style.css (line 3) background:#CDF8FF url(images/final_bg.jpg) no-repeat
Using Eclipse IDE. The line: getClass().getResource(/res/bitmaps/image.png); returns null . I have created the res
I'm trying to have images fade in with css3 once they're loaded. The problem
I have the following code: <table> <tr> <td class=first> <img src=ReallyLargeImage.png /> </td> <td
I have a problem applying css to the web pages, using spring security (3.0.7
Yes i have this line in my first upload case of the switch: $file_name
I have line: imagejpeg($this->image, $file, $quality); How can add on this image watermark.png?
I have images on iCloud and I subclassed UIDocument for them. Now i want
I have images on my website that the user needs to allow the Facebook

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.