Does jQuery's .width()
method take into account scroll bars? I'm facing an issue where I want to make the width of some elements equal to their parent element, but it seems like this method is causing problems. Here's an example of how I used jQuery:
$('#contentDiv').width($('#containerDiv').width())
In this scenario, I want #contentDiv
to have the same width as its parent #containerDiv
. However, this approach ends up cutting off part of #contentDiv
, which is visible in this fiddle.
In my real code, there are multiple elements that I need to resize using jQuery to fit inside a scrollable div. Simply setting the CSS of #contentDiv
to 100% isn't feasible due to this requirement. What would be the most effective way to handle scroll bar widths in jQuery when dealing with divs?