JQuery.width (val) error in IE - invalid argument

After loading the inner div (#book_table) via ajax, I want to resize the body body to accommodate more content.

var new_width = parseInt($('#book_table').css('width'))+407;
$('body').width(new_width);

Works in FF and Safari, but does not work in IE with "Invalid Argument". In unpacked jQuery 1.3.1 line 1049:

elem[ name ] = value;

Passing a literal value, however, works in IE:

$('body').width(1200);
+5
source share
1 answer

You must try:

var new_width = $('#book_table').width() + 407;
$('body').width(new_width);

Usage css('width')returns a string with the extension 'px', not just a number. Firefox can correctly parse "100px"as 100using parseInt, but it seems like IE is not doing this.

width() , parseInt.

+10

All Articles