how to get innerWidth of an element in jquery WITHOUT scrollbar

后端 未结 4 1780
傲寒
傲寒 2020-12-19 07:15

Given a div that has a scrollbar in it (e.g. b/c of overflow:auto), how do I get the accurate innerWidth of the element? In my example: http://jsfiddle.net/forgetcolor/2J7N

4条回答
  •  自闭症患者
    2020-12-19 07:53

    You can make another div by copying your original div, then get the width etc. Something like:

    var saveDiv = $('
    ').html($('#box2').html());

    saveDiv.innerWidth will give you 0

提交回复
热议问题