Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10880 closed bug (invalid)

$(element).is(':visible') should return true if either offsetHeight:0 or offsetWidth:0?

Reported by: [email protected] Owned by: [email protected]
Priority: undecided Milestone: None
Component: unfiled Version: 1.7
Keywords: Cc:
Blocked by: Blocking:


Hi there,

At present, $(element).is(':visible') returns true _only_ if element.offsetHeight and offsetWidth are _both_ 0px.

Surely $(element).is(':visible') should be true if _either_ element.offsetHeight or offsetWidth is 0px? Isn't 0px * anything-px = 0px-squared, so element cannot be visible?

Example html follows: please check the console. Tested in Mac FF8.01 and Safari 5.1.1.




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.js"></script>
    <div id="zero-height-nonzero-width">
        <div id="invisible" style='display:none;'>I am invisible</div>
<script type="text/javascript">
    $(document).ready(function() {
        function dumpElement(elementId) {
            var $element = $(elementId);
            var element = $element[0];

            console.log('\nElement id: ' + $element.attr('id'));
            console.log('Visible?: ' + $element.is(':visible'));
            console.log('offsetWidth: ' + element.offsetWidth);
            console.log('offsetHeight: ' + element.offsetHeight);


Change History (3)

comment:1 Changed 11 years ago by dmethvin

Owner: set to [email protected]
Status: newpending

Sounds great. Can you test with IE6/7/8 on elements including table rows and columns that are empty? That is what I believe resulted in the current code. Once you have those test cases we can consider a change.

comment:2 Changed 11 years ago by anonymous

Sure. I'll try to get the other test cases done next week.


comment:3 Changed 11 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.