What I'm trying to accomplish is a button that opens and closes a div.
The part of my code that I believe is causing this to fail is the true-false statement: if the visibility is block; if the visibility is hidden (my if/else-if statement conditions). How should I select an attribute of my HTML document from my condition statement, to check whether or not the element-state is such?
http://jsbin.com/ubuWUPe/1/edit
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<!-- block 1 -->
<script type="text/javascript">
function open_div_() {
if ( $("#_div__field").style.display = "none"; )
{
document.getElementById('_div__field').style.display = "block";
}
else if
( $("#_div__field").style.display = "block"; )
{
document.getElementById('_div__field').style.display = "none";
}
}
</script>
<!-- block 1 end -->
<meta charset=utf-8 />
<meta name="viewport" content="width=device-width">
</head>
<body>
<!-- block 2 -->
<div id="_div__field" style="display:none;">
YAY!
</div>
<div id="_div__button">
<input type="button" name="answer" value="Show" onclick="open_div_()"></button>
</div>
<!-- block 2 end -->
</body>
</html>