The effect I am trying to achieve is that when I click a button (called about), one of the div (id=homepage) gets hidden and another div (id=intro_page, which was previously hidden) is made visible.
I have the following HTML code:
<script type="text/javascript" src='js/index_script.js'></script>
.
.
<input onclick="clicked_about()" type="button" value='About'></input>
.
.
.
<div id="homepage">
content
</div>
<div id="intro_page" style="display: none">
<h1 id="intro_page_caption"> About Me </h1>
<div id="intro_main_text">
<p> I enjoy reading, swimming, jogging, painting and exploring. </p>
</div>
<div class="intro_pic1">
<figure>
<img src="img/my_picture.jpg" alt="My Picture" height="250">
<figcaption>My Picture</figcaption>
</figure>
</div>
</div>
Following is the JavaScript Code:
function clicked_about(){
document.getElementById(homepage).style.display = 'none';
document.getElementById(intro_page).style.display = 'block';
}
What I am seeing is that the code is hidden (because in HTML display is set to none), but when I click the button, nothing happens.
What am I doing wrong?