Hide or show panel using Javascript or jQuery

Posted by Vishalneeraj-24503 under JavaScript on 1/10/2018 | Points: 10 | Views : 1732 | Status : [Member] [MVP] | Replies : 0
Hi All,

I have 3 link buttons and 3 division tags on page.

I have to show one div at a time.

I mean when i click on 1st link then only 1st div should be displayed and rests 2 div tags will get hidden.

When i click on 2nd link then 2nd div will get displayed and rests should be hidden.


Below is my Javascript function :-

function ShowOrHidePanel(div_id)
{
$("#" + div_id.id).toggle();
}

<a id="lnk_skills" onclick="ShowOrHidePanel(div_1); return false;" href="javascript:ShowOrHidePanel(div_1);"></a>

<a id="lnk_tech" onclick="ShowOrHidePanel(div_2); return false;" href="javascript:ShowOrHidePanel(div_2);"></a>

<a id="lnk_user" onclick="ShowOrHidePanel(div_3); return false;" href="javascript:ShowOrHidePanel(div_3);"></a>

<div id = "div_1"></div>
<div id = "div_2"></div>
<div id = "div_3"></div>


I tried with above function by passing div id. But it's hiding 1 div and 2 divs are still showing.




Responses

(No response found.)

Login to post response