cle*_*tus 13
$("selector").hide();
$("selector").show();
Run Code Online (Sandbox Code Playgroud)
"选择器"是适当的.喜欢:
<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">
Run Code Online (Sandbox Code Playgroud)
如果隐藏或者不隐藏,该toggle()方法只会调用.show()hide()
$('#someElement').show(); //an element with id of someElement
$('.someElement').hide(); //hide elements with class of someElement
$('a').hide(); //hide all anchor elements on the page
Run Code Online (Sandbox Code Playgroud)
看到:
http://docs.jquery.com/Effects/show
和
http://docs.jquery.com/Effects/hide
另外,阅读选择器是个好主意:
http://docs.jquery.com/Selectors
| 归档时间: |
|
| 查看次数: |
9676 次 |
| 最近记录: |