Question: I was wondering if what can I do with my codes to make it shorter.
Here is my code, it is like a simple tabs.
Btw, this codes are already working, but I'm thinking that if i have many tabs then I have to repeat many click functions.
Is there a way to make my script shorter, Thanks in advance.

```
$(function () {
    $(".invMer, .invEq").hide();

    $(".mergers a").click(function () {
        $(".invMer").fadeIn();
        $(".invEq, .invPe").hide();
    });

    $(".equity a").click(function () {
        $(".invEq").fadeIn();
        $(".invMer, .invPe").hide();
    });

    $(".privateEq a").click(function () {
        $(".invPe").fadeIn();
        $(".invMer, .invEq").hide();
    });

```

Answer: 
Give all the links the same class, and a data attribute that says which tab it should open. So something like:

```
<div class="mergers">
    <a class="tablink" href="#" data-tab="invMer">Mergers</a>
</div>

```

And all the tab DIVs should also have a common class:

```
<div class="tabdiv" id="invMer">
    ...
</div>

```

Then you can use a single handler:

```
$(".tablink").click(function() {
    var tab = '#' + $(this).data("tab");
    $(".tabdiv").not(tab).hide();
    $(tab).show();
});

```
Use a data attribute

```
<a data-show=".invPe">

```

and do

```
$("a[data-show]").on("click", function () {
    var selector = $(this).data("show"); 
    $(".invMer, .invEq, .invPe").hide();
    $(selector).fadeIn();
});

```