Bug Tracker


Ticket #1424 (closed bug: fixed)

Opened 7 years ago

Last modified 7 years ago

Correction of height and width methods

Reported by: hobbit Owned by:
Priority: major Milestone: 1.2.2
Component: core Version: 1.1.3
Keywords: height, width Cc:
Blocking: Blocked by:


jQuery.each( [ "height", "width" ], function(i,n){
  jQuery.fn[ n ] = function(h) {
    return h || h===0?
      this.css( n, isNaN(h)? h : h + "px" ):
      ( this.length ? jQuery.css( this[0], n ) : null );
The (h
h===0) checking works right with undefined, null and NaN values. The original checking was h==undefined. Example the IE doesn't work correct with NaN value.

And if the h parameter is a string, but doesn't closed with "px" string, then isNaN checking is right.

Change History

comment:1 Changed 7 years ago by brandon

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from 1.1.4 to 1.2.2

This works for me with jQuery 1.2.1

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.


Add a comment

Modify Ticket

as closed

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.