Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

196
Visualizações
jQuery removeClass on iFrame button click

I wrote some code to addClass to elements to open an iFrame imported by Shopify on WordPress and it works. But now, I want to close the iFrame by removing the class on my website element. I've tried a lot of things but it dosen't work

Here is my code :

jQuery(document).ready(function( $ ) {
    $(document).ready(function() {
        $('.cart-button').click(function() {
            $('.shopify-buy-cart-wrapper').addClass('is-active is-visible');
            $('.shopify-buy-cart-wrapper iframe').addClass('is-block');
            return false;
        });
        //$("iframe").contents().find("button .shopify-buy__btn--close").click(function(){
        $('.shopify-buy__btn--close').click(function() {
            $('.shopify-buy-cart-wrapper').removeClass('is-active is-visible');
            $('.shopify-buy-cart-wrapper iframe').removeClass('is-block');
        }); 
    });
});

Open cart is working, but now I want to close the cart

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you want to remove multiple classes with jQuery removeClass() you have to pass them as an array, not as a string.

Also, any event listener should be attached only after the element has been inserted in the DOM. If you define the event listener but the element is created afterwards, it won't work.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda