I have the following buttons:
First button:
<button id="modal-btn" class="button btn-cart btn-verde-claro"> <span>Comprar</span> </button>
Second button:
<div class="btn-comprar-fixed-mobile" id="btn-comprar-fixed-mobile" style="display: none">
<button class="button btn-cart btn-verde-claro"><span>Comprar</span></button>
</div>
I wanted that when the first button appeared, the second did not appear and vice versa. When the second appears on the screen, the first one is hidden.
I made the function in jQuery using .is(':visible')
, but it did not work, because I wanted to see if the element was being displayed on the screen, not with display: none
or display: block
.
Function Code:
$j(window).scroll(function() {
console.log('fazendo');
if($j('#modal-btn').is(':visible')){
console.log('if');
$j('#btn-comprar-fixed-mobile').css('display','none');
} else{
console.log('else');
$j('#btn-comprar-fixed-mobile').css('display','block');
}
});