如何使用jQuery显示隐藏的div? [英] How to display hidden div using jquery?

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

问题描述

我想使用jquery显示一个隐藏的div.由于某些原因,show()在我的示例中不起作用.如果我删除了hidden属性并使用hide(),那确实可行.

I'd like to display a hidden div using jquery. For some reason, show() isn't working in my example. If I remove the hidden attribute and use hide(), that does work.

有什么想法我在做什么错吗?

Any ideas what I'm doing wrong?

<div id="mydiv" style="visibility:hidden">some text</div>
<button onclick="$('#mydiv').show();">click me</button>

http://jsfiddle.net/5pmLw8r2/

推荐答案

尝试使用display:none而不是visible:hidden

try using display:none instead of visibility:hidden

.show和.hide()切换显示属性而不是可见性

the .show and .hide() toggle display attribute not visibility

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

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