I'm trying to figure out how to change this code so that when someone clicks on a link for more information, all other divs are hidden. For example, if someone clicks on article 1's more information link...then click's on article 2's informaton link, I want the article1b div to automatically hide. Right now, the "close" link needs to be clicked on to hide it first. I like the close link, but is there a way this code can be changed so I can show one div and hide several others? (I'm just a beginner, so I might need thinks really explained.) Thank you!
Here is the code I have so far:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
function show( id ) {
document.getElementById(id).style.display = 'block';
}
function hide( id ) {
document.getElementById(id).style.display = 'none';
}
</script>
<style>
<!-- may fine tune, move to external stylesheet -->
.hidden {display:none;}
.articlelink {text-decoration: underline}
</style></head>
<body>
<p>Article 1 copy
<div onclick="show('article1b'); hide('articlelink1')" class="articlelink" id="articlelink1">more info</div></p>
<div id="article1b" class="hidden">
<p>The rest of article 1</p>
<div onclick="hide('article1b'); show ('articlelink1')" class="articlelink">
<p>close</p>
<br>
<br>
</div></div>
<p>Article 2 copy
<div onclick="show('article2b'); hide('articlelink2')" class="articlelink" id="articlelink2">more info</div></p>
<div id="article2b" class="hidden">
<p>The rest of article 2</p>
<div onclick="hide('article2b'); show ('articlelink2')" class="articlelink">
<p>close</p>
<br>
<br>
</div></div>
<p>Article 3 copy
<div onclick="show('article3b'); hide('articlelink3')" class="articlelink" id="articlelink3">more info</div></p>
<div id="article3b" class="hidden">
<p>The rest of article 3 </p>
<div onclick="hide('article3b'); show ('articlelink3')" class="articlelink">close</div></div>
</body>
</html>
Here is the code I have so far:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
function show( id ) {
document.getElementById(id).style.display = 'block';
}
function hide( id ) {
document.getElementById(id).style.display = 'none';
}
</script>
<style>
<!-- may fine tune, move to external stylesheet -->
.hidden {display:none;}
.articlelink {text-decoration: underline}
</style></head>
<body>
<p>Article 1 copy
<div onclick="show('article1b'); hide('articlelink1')" class="articlelink" id="articlelink1">more info</div></p>
<div id="article1b" class="hidden">
<p>The rest of article 1</p>
<div onclick="hide('article1b'); show ('articlelink1')" class="articlelink">
<p>close</p>
<br>
<br>
</div></div>
<p>Article 2 copy
<div onclick="show('article2b'); hide('articlelink2')" class="articlelink" id="articlelink2">more info</div></p>
<div id="article2b" class="hidden">
<p>The rest of article 2</p>
<div onclick="hide('article2b'); show ('articlelink2')" class="articlelink">
<p>close</p>
<br>
<br>
</div></div>
<p>Article 3 copy
<div onclick="show('article3b'); hide('articlelink3')" class="articlelink" id="articlelink3">more info</div></p>
<div id="article3b" class="hidden">
<p>The rest of article 3 </p>
<div onclick="hide('article3b'); show ('articlelink3')" class="articlelink">close</div></div>
</body>
</html>