import $ from 'jquery'; $(document).ready(function () { let tabs = $('.js-tabs'); if (tabs.length) { tabs.each(function(){ let _this = $(this), btn = _this.find('.js-tabs-btn'), item = _this.find('.js-tabs-item'); btn.on('click', function(e){ e.preventDefault(); let _thisBtn = $(this), index = _thisBtn.index(); btn.removeClass('active'); _thisBtn.addClass('active'); item.hide(); item.eq(index).fadeIn(); }); }); } });