如何使用JQuery隐藏和显示HTML元素? [英] How to I hide and show HTML elements using JQuery?

查看:110
本文介绍了如何使用JQuery隐藏和显示HTML元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用JQuery隐藏和显示HTML元素而没有任何特殊效果?

How to I hide and show HTML elements using JQuery without any special effects?

推荐答案

使用 hide() show() 方法:

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.

这篇关于如何使用JQuery隐藏和显示HTML元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆