jQuery Swapping Elements

Posted by zuk1 on Stack Overflow See other posts from Stack Overflow or by zuk1
Published on 2008-10-24T15:04:43Z Indexed on 2010/04/04 4:13 UTC
Read the original article Hit count: 286

Filed under:

Ok let me make an example:

<head>
<script type="text/javascript">
$(document).ready(function(){

    $("#options_2").hide();
    $("#options_3").hide();

});
</script>
</head>
<body>
<div id="options_1">option 1</div>
<div id="options_2">option 2</div>
<div id="options_3">option 3</div>
<a href="" class="selected">choose option 1</a>
<a href="">choose option 2</a>
<a href="">choose option 3</a>
</body>

As you can see only option 1 is visible by default, and the link you click to show option 1 has the class="selected" by default, showing the user that that option is currently selected. I basically want it so that when they click "choose option 2" the options 1 div hides itself and the options 2 div shows itself, and then gives the second link the selected class and removes the class from the image link.

It basically just tabs using links and divs but due to the format I have to display it in I cannot use any of the tabs plugins I have found online.

© Stack Overflow or respective owner

Related posts about jQuery