.show()和.css({'display':'block'})有什么区别? [英] What's the difference between .show() and .css({'display':'block'})?

查看:1078
本文介绍了.show()和.css({'display':'block'})有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是通过更改

$('#thisElement').show();

$('#thisElement').css({'display':'block'});

其中 #thisElement display:none;

这两个表达式有本质区别吗?

Is there a fundamental difference in these two expressions?

推荐答案

假设你在开头有这个:

<span id="thisElement" style="display: none;">Foo</span>

$('#thisElement').show();

您将获得:

<span id="thisElement" style="">Foo</span>

while:

$('#thisElement').css({'display':'block'});

会:

<span id="thisElement" style="display: block;">Foo</span>

所以有区别。

这篇关于.show()和.css({'display':'block'})有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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