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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:33:18+00:00 2026-05-30T22:33:18+00:00

I have four text boxes all with similar code. Each one on hover fades

  • 0

I have four text boxes all with similar code. Each one on hover fades out and displays an image behind it via CSS3 transition. But with the box’s title I need the same thing to occure so I wrote a small chunk of code to do this. The only issue I can’t solve is getting the hover title effect to work for only its fellow <section> partner. I know I can write 4 different chunks of code to do this each having different classes, but that’s annoying and if I don’t have to I’d rather not.

My html:

<section class="home-text-box services" >
    <div class="txt-box-title">
        <h2 class="align-left">
            <a class="txtbox-link" href="<?php bloginfo('url'); ?>/services" class="txt-box font-droid" title="Services" alt="Services" >What We Offer</a>
        </h2>
    </div>

    <a href="<?php bloginfo('url'); ?>/services" ><div class="services-img"></div></a>
    <a class="txtbox-img txtbox-main-img" href="<?php bloginfo('url'); ?>/services" > <?php the_post_thumbnail('txt-box'); ?> </a>

</section>

The CSS part is working great when hovering over images I get the fade out effect I was looking for. Now I just want to select the “txtbox-main-img” class of the <a> tag when hovering over the <txt-box-title> <a> tag.

My jQuery is selecting all of the boxes, obviously, because they have the same class. But I’d rather not write 4 different pieces of hover code if I don’t have to.

My jQuery

$('.txtbox-link').hover(function(){
    $('.txtbox-main-img').css('opacity' , '0.0');
},function(){
    $('.txtbox-main-img').removeAttr("style");
});

My CSS in case it is needed:

.txtbox-main-img {
    z-index: 10;
    opacity: 100;
    transition: opacity 0.25s linear;
    -moz-transition: opacity 0.25s linear;
    -webkit-transition: opacity 0.25s linear;
    -o-transition: opacity 0.25s linear;
}

.txtbox-main-img:hover {
    opacity: .01;
    transition: opacity 0.25s linear;
    -moz-transition: opacity 0.25s linear;
    -webkit-transition: opacity 0.25s linear;
    -o-transition: opacity 0.25s linear;
}

div.services-img {
    position: absolute;
    background: url('images/services-img.jpg');
    width: 200px;
    height: 122px;
    top: -1px;
z-index: -10;
}
  • 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-30T22:33:19+00:00Added an answer on May 30, 2026 at 10:33 pm

    Try using the following:

    $('.txt-box-title').hover(function(){
        $(this).siblings('.txtbox-main-img').css('opacity' , '0.0');
    },function(){
        $(this).siblings('.txtbox-main-img').removeAttr("style");
    });
    

    The above works on the assumption that you want to perform the same actions as you posted in your hover() code on the .txtbox-main-img element while hovering over the .txt-box-title element.

    I’d suggest, though, that instead of directly manipulating the style of the element, that you add, and remove, a class to manipulate the presentation:

    $('.txt-box-title').hover(function(){
        $(this).siblings('.txtbox-main-img').addClass('faded');
    },function(){
        $(this).siblings('.txtbox-main-img').removeClass('faded');
    });
    

    And define the faded class in your CSS:

    .faded {
        opacity: 0;
    }
    

    References:

    • addclass().
    • removeClass().
    • siblings()
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some databases that have four files each; one for PRIMARY, IDX, IMAGE,
I have two web pages: one consists of four asp.net text boxes and one
I have an excel file with four text columns: one of them is called
I have an Android ListView with rows that include one checkbox, and four text
I have four flags Current = 0x1 Past = 0x2 Future = 0x4 All
I have four UINavigationControllers assigned each to a tab in a UITabBarController. Each UINavigationController
I have four models that are related to one another, the way I have
I have four sheets in a spreadsheet. On each sheet there is a textbox.
I have four images on a page that on hover, needs to replace the
Four text boxes are in a JSP page. After entering first text box, when

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.