Reputation: 1926
In this script below, I set an element to visible or hidden as you'll can see. However, once .closeAdd is shown it will not hide if the script comes to the second part in the if statement. I've noticed that jQuery sets it to display:block
when it uses show(). Any idea how I can set this right?
if(type === 'user' && action === 'add') {
if($('.closeAdd').is(':hidden')) {
$('.closeAdd').show();
}
} else { //If it's visible and it comes to this part, it will not hide...
if($('.closeAdd').is(':visible')) {
$('.closeAdd').hide();
}
}
Upvotes: 0
Views: 241
Reputation: 1201
Since display is being updated you can check it in your function as it follows:
if(type === 'user' && action === 'add') {
if($('.closeAdd').css("display") == 'none') {
$('.closeAdd').show();
}
} else {
if($('.closeAdd').css("display") == 'block') {
$('.closeAdd').hide();
}
}
Upvotes: 1