Should return parent.offsetWidth, as elem.width is an int, and not a str with "px" at the end.