更新时间:2022-11-10 19:09:21
Using the hide()
and show()
methods:
$("selector").hide();
$("selector").show();
其中选择器"是合适的.喜欢:
Where "selector" is whatever is appropriate. Like:
<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">
toggle()
方法仅在隐藏时调用show()
,或者在其隐藏时调用hide()
不是.
The toggle()
method just calls show()
if hidden or hide()
if its not.