jQuery('.tab-contents').each(function(i,el){ el.id = 'tab-contents_'+i; }); jQuery('.buttons-tab').each(function(i,el){ jQuery(this).attr('data-id', 'tab-contents_'+i); }); jQuery(".buttons-tab").click(function(){ curr_id = jQuery(this).attr('data-id'); jQuery('#'+curr_id).toggle(500); jQuery('.tab-contents').not('#'+curr_id).hide(); });
Jagdish Sarma Asked question October 2, 2020