clientWidth and offsetWidth returns NaN

clientWidth and offsetWidth returns NaN

I am trying to handle a resize for JQGrid with a snippet of code below

                var width = $("#divGridContainer").attr('clientWidth');
                if (width == null || width < 1) {
                    // For IE, revert to offsetWidth if necessary
                    width = $("#divGridContainer").attr('offsetWidth');
                }
                width = width - 2; // Fudge factor to prevent horizontal scrollbars

                alert(width);

It always throws the response to width as NaN. What am I missing out?