简体   繁体   中英

show div when another div is visible

I am trying make make a hidden div visible when a div which is on a timer shows up for a promotion. Is is something that is doable? Let me know if the question is unclear i can try to rephrase it

here is some Jquery i have so far

$('.specialSignup').css('display', 'none');
    if ( $('.homePromo').filter(':visible'){
        $('.specialSignup').css('display', 'block');
    } 

What are you using to show the first div? How is it being shown?

Without knowing all the information it's hard to give precise answers, but yes this is definitely possible. I'm assuming Javascript is toggling the visibility.

Since I'm assuming javascript, I'll take a wager that whatever is triggering the visibility is adding/removing a css class from the div. In order for the javascript to do that, it needs to find which div needs to toggle. It's probably looking for a certain id or class that's associated with the div.

Try making the second div have a similar id or class and see if that helps.

If not, I'll need more detail. ie what code is triggering the div visibility.

Edit:

Based on the new code you posted, your if statement is missing a end )

It should be this:

$('.specialSignup').css('display', 'none');
if ( $('.homePromo').filter(':visible')){
    $('.specialSignup').css('display', 'block');
} 

without any additional information..

When the timer times out, trigger either an event or function call to show the hidden layer.

You can detect the display property using: $(element).is(":visible"); . Should work with .show() and .hide() as well as .toggle() as they affect display not visibility .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM