I can't seem to get my JavaScript to fully work. The first if statement works fine but the second part will not execute when I click the button again. To understand my problem just copy my code and save it as a .html or .htm file and test it yourself to see if you can fix it for me and then repost the working code. Thanks,
Code:
<html>
<head>
<script type="text/javascript">
function extra()
{
if (document.getElementById('button').value="Show Message")
{
document.getElementById('msg').style.display="block";
document.getElementById('button').value="Hide Message";
}
else if (document.getElementById('button').value="Hide Message")
{
document.getElementById('msg').style.display="none";
document.getElementById('button').value="Show Message";
}
}
</script>
<style type="text/css">
#msg{display:none;}
</style>
</head>
<body>
<input type="submit" value="Show Message" id="button" onClick="extra();"/> <br/><br/>
<div id="msg">Hey this is a message.</div>
</body>
</html>