2
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 was hidden.
I did the function in jQuery using the .is(':visible')
, but it did not work, because I wanted to see if the element was being displayed on the screen, if 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');
}
});
I think he meant that the first button is fixed, and when it appeared or second, the first disappeared and lives-versa... by the way, the second that is fixed rs
– Sam
@dvd that’s right. But I managed to make it work from this code, I only changed a few things in the function.
– Matheus Portela