Search code examples
javascriptjqueryslidetoggle

Slidetoggle Not working properly on child element of the parent


On clicking .cart-contents-toggle the #cartplus-dropdown div should slide down and at the same time slide up without clicking on it a second time. Here is the URL where this is implemented: Website Link

jQuery(document).ready(function() {
  jQuery('#cartplus-dropdown').hide();
  jQuery('.cart-contents-toggle').on("click", function() {
    jQuery('#cartplus-dropdown').slideToggle();
  });
});

Solution

  • Please use the updated code below and let me know if you have any issue or query.

    jQuery(document).ready(function() {
     jQuery('.cart-contents-toggle').on("click", function() {
       jQuery('#cartplus-dropdown').toggle();
        jQuery('#cartplus-dropdown').slideToggle();
    
      });
    });
    

    Hope this may be helpful to you.