How do I shorten my JQuery tabs?
The visual style of your tabs is actually independent of their functionality. That is, they all behave as tabs, regardless of how they look.

So, while you could make your code more generic by making the selector strings on the fly ($(".tab-content-" + styleName) etc.), I'd recommend something different.

I'd start by separating the classes that describe style from the ones that describe function. Then I'd use the structure of the markup to figure out the rest; not everything needs a class name.

I.e. given this markup, which is slightly changed/simplified from yours

&lt;div class="tabs tabs-style1"&gt;
  &lt;ul class="tabs-list"&gt;
    &lt;li class="current" data-tab="tab-1"&gt;Tab One&lt;/li&gt;
    &lt;li data-tab="tab-2"&gt;Tab Two&lt;/li&gt;
    &lt;li data-tab="tab-3"&gt;Tab Three&lt;/li&gt;
    &lt;li data-tab="tab-4"&gt;Tab Four&lt;/li&gt;
  &lt;/ul&gt;

  &lt;div id="tab-1" class="current"&gt;
    &lt;p&gt;Lorem ipsum...&lt;/p&gt;
  &lt;/div&gt;

  &lt;div id="tab-2"&gt;
    &lt;p&gt;Duis aute...&lt;/p&gt;
  &lt;/div&gt;

  &lt;div id="tab-3"&gt;
    &lt;p&gt;Ut enim...&lt;/p&gt;
  &lt;/div&gt;

  &lt;div id="tab-4"&gt;
    &lt;p&gt;Sed do eiusmod...&lt;/p&gt;
  &lt;/div&gt;
&lt;/div&gt;


The code can be shortened to

$(".tabs").each(function () {
  var container = $(this);
  container.find(".tabs-list li").on("click", function () {
    var tab = $(this),
        target = tab.data("tab");
    tab.addClass("current")
      .siblings().removeClass("current");
    container.children("#" + target).addClass("current")
      .siblings("div").removeClass("current");
  });
});


for any and all "tab areas" on the page. It'll also work if you add new styles later, or remove any of ones you have. I.e. the visual style is decoupled from the behavior. Also, you only need to change the class name in one place to re-style an entire tab area.

CSS-wise, simply scope your rules to .style1, .style2 etc. and perhaps use the direct-descendant operator, while keeping the base styling common for all styles

.tabs-style1 .tabs-list { ... }
.tabs-style1 .tabs-list li { ... }
.tabs-style1 &gt; div { /* tab content styling */ }


Here's a demo (it's ugly - just demonstrating the functionality)