1

Anyone knows how to convert from jQuery to Vanilla JS?

This code i share for slide up / down / toggle

jQuery(document).ready(function () { 
        autoExpand = setTimeout(function () {
            jQuery("#catfish_expanded").slideDown('slow');
        }, 2000);
    
        var interval = null;
        autoCollapsed = function (time) {
            interval = setTimeout(function () {
                jQuery("#catfish_expanded,#catfish_collapsed").slideToggle("slow");
            }, time);
        }
        autoCollapsed(12000);
    
        jQuery("#catfish_collapsed").on("click", function () {
            jQuery("#catfish_expanded,#catfish_collapsed").slideToggle("slow");
            autoCollapsed(10000);
        });
        jQuery(".close_txt").on("click", function () {
            jQuery("#catfish_expanded,#catfish_collapsed").slideToggle("slow");
            clearTimeout(interval);
        }); });
Azka Afiq
  • 11
  • 2
  • 1
    Does this answer your question? [Is there an easy way to convert jquery code to javascript?](https://stackoverflow.com/questions/978799/is-there-an-easy-way-to-convert-jquery-code-to-javascript) – Samball Mar 31 '22 at 09:32
  • Start here: https://youmightnotneedjquery.com/ – freedomn-m Mar 31 '22 at 09:55
  • Does this answer your question: [Vanilla JS for slide up/down](https://stackoverflow.com/questions/37338030/vanilla-js-version-of-jquery-slidedown-on-dropdown-menu) – freedomn-m Mar 31 '22 at 09:58

0 Answers0