Using hide()and show()methods:
$("selector").hide();
$("selector").show();
If the “selector” is all that fits. How:
<script type="text/javascript">
$(function() {
$("#mybutton").click(function() {
$("#mydiv").toggle();
});
});
</script>
<div id="mydiv">
This is some text
</div>
<input type="button" id="mybutton" value="Toggle Div">
The method toggle()simply calls show()if it is hidden or hide()if it is not.
source
share