In my code , I want to show the default content of first link on page . Below is my code , Here when I click on some link that time it it loads its content , Instead of that I want to show first link content on pages load , After user cliks on any link the the content has to get change
<!DOCTYPE html>
<html>
<head>
<script src="jquery.js" type="text/javascript"></script>
</head>
<body>
<div id="nav">
<a href="" id="#content1">Show content 1</a>
<a href="" id="#content2">Show content 2</a>
<a href="" id="#content3">Show content 3</a>
</div>
<div id="contents" style="width: 200px; height: 40px; border: dotted; margin-top: 20px;">
<div id="content1" class="toggle" style="display:none">show the stuff1</div>
<div id="content2" class="toggle" style="display:none">show the stuff2</div>
<div id="content3" class="toggle" style="display:none">show the stuff3</div>
</div>
<script>
$("#nav a").click(function(e){
e.preventDefault();
$(".toggle").hide();
var toShow = $(this).attr('id');
$(toShow).show();
});
</script>
</body>
</html>
Below is JSFiddle link