我刚刚通过更改获得了一个可以工作的脚本
$('#thisElement').show();
至
$('#thisElement').css({'display':'block'});
其中
#thisElement
已加载为具有 display:none;
这两种表达方式有根本区别吗?
最佳答案
假设你一开始有这个:
<span id="thisElement" style="display: none;">Foo</span>
你打电话的时候:
$('#thisElement').show();
你会得到:
<span id="thisElement" style="">Foo</span>
尽管:
$('#thisElement').css({'display':'block'});
做:
<span id="thisElement" style="display: block;">Foo</span>
所以,是的,有区别。
关于jquery - .show() 和 .css( {'display' :'block' }) 有什么区别?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3641532/