Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!