Created
November 11, 2010 04:49
-
-
Save christianhager/672027 to your computer and use it in GitHub Desktop.
Toggle flere
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//en av linkene blir trykket | |
$(".link").click(function(){ | |
var id = $(this).attr("id"); // henter ut riktig id | |
showThisBox(id); // vi kaller på funksjonen som viser en, gjemmer de andre | |
return false; //for å unngå at man hopper i skjermen | |
}); | |
//vis en, gjem de andre | |
function showThisBox(id){ | |
//looper alle boksene | |
$(".box").each(function(){ | |
//vis om det var denne vi skulle vise | |
if($(this).attr("id")==id){ | |
$(this).show(); | |
//gjem ellers | |
}else{ | |
$(this).hide(); | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a class='link' id='1' href='#'>Link 1</a> | |
<a class='link' id='2' href='#'>Link 2</a> | |
<a class='link' id='3' href='#'>Link 3</a> | |
<div class='box' id='1'> box 1 </div> | |
<div class='box' id='2'> box 2 </div> | |
<div class='box' id='3'> box 3 </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.box{display:none;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment