To get element's width with margins, you can use $modalToolbar.outerWidth( true )