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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:20:16+00:00 2026-06-15T06:20:16+00:00

I came across an example of revealing a hidden div which is inside an

  • 0

I came across an example of revealing a hidden div which is inside an element using css only

<style type="text/css">
#shopCart:hover .shopCartDetail {
    display: block;
}
</style>

<div id="shopCart">
Shop Cart
<div class="shopCartDetail"><style>.shopCartDetail {display:none}</style>
    This is Shop Cart Detail</div>
</div>

Working example here http://jsfiddle.net/7DRTD/

In my scenario, the style display:none is created by jQuery. Revealing the hidden div using hover does not work: http://jsfiddle.net/Z2mtF/

What can be the issue here? The html code looks same, both examples add inline style to the div.

The question is: why does the second scenario not work?

Thank you.

  • 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-06-15T06:20:17+00:00Added an answer on June 15, 2026 at 6:20 am

    In a general sense, styles applied directly to an individual element take precedence over settings from the stylesheet. This is (part of) the “cascading” effect that is the “C” in “CSS”. So when you hide the element with jQuery with the following in your document ready:

    $(".shopCartDetail").css("display","none");
    

    …it is equivalent to adding style="display:none" directly to the element, which has the same “problem”: http://jsfiddle.net/Z2mtF/2/

    This is not the same as applying a class to the element, which is what your “emulation” above was doing with the <style> element inside the <div>.

    So the hover rule isn’t important enough to take effect. One way to fix this is to make the hover rule important:

    #shopCart:hover .shopCartDetail
    {
        display: block !important;
    }
    

    Demo: http://jsfiddle.net/Z2mtF/1/

    Settings in the stylesheet marked as !important will take precedence over the inline style attributes.

    Note that it’s tidier if you use .show() and .hide() instead of explicitly setting the display property via the .css() method.

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

Sidebar

Related Questions

I came across this great JQuery example of using a slidetoggle. I want to
I came across this free example website design template which has some links across
I came across this example on SO which gives a solution to create a
I came across this example class http://www.boost.org/doc/libs/1_49_0/libs/smart_ptr/sp_techniques.html#as_lock and I'm struggling with the syntax. class
While I was reading Oracle Swing documentation, I came across this example of a
For class specific new_handler implementation, i came across the following example in book effective
Going through some documentation on modifying CGImageRef data, I came across a strange example
I came across places where floors and ceilings are neglected while solving recurrences. Example
The other day, I came across this construct: static_cast<size_type>(-1) in some example C++ code,
Just came across this by Chris Coyier - http://css-tricks.com/examples/CSSTabs/ Can anyone explain me, how

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.