How can I rewrite this jQuery code in pure JavaScript?

  • 0
    How do I rewrite this jQuery code in pure JavaScript? this is the logic of a simple filtering of buttons by blocks.
    $(function(){
    
            let filter = $('[data-filter]');
            $('[data-filter="all-product"]').addClass('active-tab');
    
    
            filter.on('click', function(){
               
                let category = $(this).data('filter');
                console.log(category);
                
                if (category == 'all-product') {
                    $('[data-category]').removeClass('hide');
                }
                else {
                    $('[data-category]').each(function() { 
    
                        let workCat = $(this).data('category');
        
                        if (workCat != category) {
                            $(this).addClass('hide');
    
                        }               
                        else {
                            $(this).removeClass('hide');
                  
                        }
                  
        
                    });
                }
    
    
                
            });
    
        })
    JavaScript Jase Johnson, May 21, 2019

  • 1 Answers
  • 0
    jQuery - & gt; js at your service!
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!