[JQuery]几个易混淆概念的总结

逄嘉木
2023-12-01

1.[display:none 与 visibility:hidden 的区别]

display:none means that the tag in question will not appear on the page at all (although you can still interact with it through the DOM). There will be no space allocated for it between the other tags.

display:none 表示设置此属性的标签元素在页面中不会出现,并且此元素并不会在其他元素之间占位。

visibility:hidden means that unlike display:none, the tag is not visible, but space is allocated for it on the page. The tag is rendered, it just isn't seen on the page.

visibility:hidden和前者不同的地方在于,设置此属性的标签元素不可见,但是会在页面中展位,并且该元素也会被css样式所修饰,只是不可见而已。

input[type=hidden] :HIDDEN is a TYPE attribute value to the INPUT element for FORMs. It indicates a form field that does not appear visibly in the document and that the user does not interact with. It can be used to transmit state information about the client or server.

[Notice]在JQuery中由可见性过滤器找到的元素包括:display为none的元素、隐藏的文本区域(type="hidden")以及visibility:hidden的元素

2.[ $('input') 与 $(':input')的区别]

$('input') = with only the element name, selects only HTML elements.

$(':input') = with the colon, selects/filter all form input type elements, including inputselect textarea , and button elements.

3.[$(‘element:hidden’) 与$('element :hidden') 的区别]

可见性过滤选择器与子代选择器的区别
 类似资料: