Cameleon
Cameleon

Reputation: 463

Show, hide in same time two objects Jquery?

Jquery question

So i got if condition, in this condition I make div visible and want other to hide in that time.

if(pass == '1') 
// show in msgOK-IDnumber
$("div#msgOK-" + id).delay(200).fadeIn(1500).delay(3000).fadeOut(1500);
// hide ul.star-rating
????????????????????????????????

html

<ul class="star-rating" id="{$ID}">
<li class="current-rating" style="width:10%;"></li>
<li><a href="#" class="one-star"></a></li>
<li><a href="#" class="two-stars"></a></li>
<li><a href="#" class="three-stars"></a></li>
<li><a href="#" class="four-stars"></a></li>
<li><a href="#" class="five-stars"></a></li>
</ul>

<div style="display:none;" id="msgOK-{$ID}">Sucessfull</div>

Then after delay, everything need to go back to first state.

Upvotes: 2

Views: 1120

Answers (1)

Shadow Wizzard
Shadow Wizzard

Reputation: 66388

You have to use block of code using the { and }:

if(pass == '1') {
    // show in msgOK-IDnumber
    $("div#msgOK-" + id).delay(200).fadeIn(1500).delay(3000).fadeOut(1500);

    // hide ul.star-rating
    $("ul .star-rating").fadeOut(1500);
}

Without wrapping it as block, you can execute only one command for if statement, that's probably what you experienced.

Upvotes: 2

Related Questions