Question
jQuery hide one element based on another element's visibility
I have two DIVs on a page and some jQuery plugin stuff going on. What I need to do is hide element A when element B's visibility is set to none.
Answer
Refer this
Below if div A is visible then B will hide and if A is hidden then B will show. You can change the display to none and block for A and refresh the page to see it working
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head2">
<title></title>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.2.min.js"></script>
<script type="text/javascript">
$(function () {
if ($("#dvA").is(":hidden")) {
$("#dvB").css("display", "block");
} else {
$("#dvB").css("display", "none");
}
});
</script>
</head>
<body>
<form id="form2">
<div id = "dvA" style = "display:none">A</div>
<div id = "dvB">B</div>
</form>
</body>
</html>