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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:31:15+00:00 2026-05-23T01:31:15+00:00

I have 9 items on a grid, I want all items to have 0.5

  • 0

I have 9 items on a grid, I want all items to have 0.5 opacity on every item and only when hovered over should the div/item and everything inside have 1.0 opacicty.

Here is the JS

$('.gallery-single').css({ opacity: 0.5 });

$('.gallery-single a').mouseover(function(){
    $('.gallery-single-title', this).css('display', 'block');
        $('.gallery-single', this).css({ opacity: 1 });
});
$('.gallery-single a').mouseout(function(){
    $('.gallery-single-title', this).css('display', 'none');
        $('.gallery-single', this).css({ opacity: 0.5 });
}); 

HTML

<div class="gallery-single">
<a href="#" title="">
<div class="gallery-single-title hide">Some text goes here</div>
<div class="gallery-single-img"><img src="http://img.youtube.com/vi/code/0.jpg" width="300" height="200" /></div>
</a>
</div>

All items are at opacity 0.5 when loaded but opacities are not changed when focused.
What am I doing wrong here?

  • 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-23T01:31:16+00:00Added an answer on May 23, 2026 at 1:31 am

    The problem is that .gallery-single is an ancestor of the anchor (i.e. it’s outside the anchor). The $(selector, this) format looks for the selector within this. Instead, use .closest():

    $(this).closest('.gallery-single').css(...);
    

    Sidenote: jQuery gives this warning about mouseover (also applies to mouseout):

    This event type can cause many
    headaches due to event bubbling. For
    instance, when the mouse pointer moves
    over the Inner element in this
    example, a mouseover event will be
    sent to that, then trickle up to
    Outer. This can trigger our bound
    mouseover handler at inopportune
    times. See the discussion for
    .mouseenter() for a useful
    alternative.

    You should use mouseenter (and mouseleave) instead (or the hover() function which conveniently combines the two).

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

Sidebar

Related Questions

So I have this Xaml inside a ListBox Item Template: <ListBox.ItemTemplate> <DataTemplate> <Grid Height=22
I have about 700 items to display in the grid view. On a Samsung
currently I have a requirement to display related items in a multi level grid.
I have some items in my .emacs that I don't want to run if
I am trying to build a grid of items, all dynamically (rows and columns)
I have an IEnumerable<GridItem> items containing a list of thousands of items, each item
All, I have simple accordion with 2 accordion items each containing 4 text boxes.
I have a ListView that presents items horizontally. Each Item is a 1 column
I have a list of items which I want the user to be able
I have a listbox containing checkboxes. I want to get all the checkbox checked

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.