Bug Tracker

Opened 7 years ago

Closed 7 years ago

#12473 closed bug (worksforme)

why in input tag<input id="test" style="visibility:hidden;"/> that $("#test").is(":hidden") result is not right?

Reported by: 赖扬文 785490650@… Owned by:
Priority: low Milestone: None
Component: css Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

Description

<input id="test" style="visibility:hidden;"/> <script>

$(function(){

var isVisible=$("#test").is(":visible"); var isHidden=$("#test").is(":hidden"); alert("isVisible:"+isVisible);should false ,but true, why? alert("isHidden:"+isHidden);should true, but false,why? if replace "input" to "div" that will been right 如果将input替换成div的话就不会有这样的bug

});

</script>

Change History (2)

comment:1 Changed 7 years ago by anonymous

<input id="test" style="visibility:hidden;"/> <script>

$(function(){

var isVisible=$("#test").is(":visible"); var isHidden=$("#test").is(":hidden"); alert("isVisible:"+isVisible);should false ,but true, why? alert("isHidden:"+isHidden);should true, but false,why? if replace "input" to "div" that will been right 如果将input替换成div的话就不会有这样的bug

});

</script> </body>

comment:2 Changed 7 years ago by mikesherov

Component: unfiledcss
Priority: undecidedlow
Resolution: worksforme
Status: newclosed

Thanks for the report, but please ask for help on the forum!

The is(":visible") selector does not check for the "visibility" property, which just deals truly with opacity, but rather checks for the "display" property.

The reason it works for div and not input is that a div that has visibility hidden and no content truly has no dimensions and is therefore effectively hidden, but that is not true of inputs.

Note: See TracTickets for help on using tickets.