?parseInt(oDiv.style.width)跟oDiv.offsetwidth有差別嗎
parseInt(oDiv.style.width)跟oDiv.offsetWidth有差別嗎
為什么oDiv.style.width=parseInt(oDiv.style.width)-1+'px';沒反應(yīng) 不往左也不往右 就是不動呢?
oDiv.style.width=oDiv.offsetWidth-1+'px';就有變化??
parseInt(oDiv.style.width)跟oDiv.offsetWidth有差別嗎
為什么oDiv.style.width=parseInt(oDiv.style.width)-1+'px';沒反應(yīng) 不往左也不往右 就是不動呢?
oDiv.style.width=oDiv.offsetWidth-1+'px';就有變化??
2016-09-15
舉報
2016-09-15
區(qū)別在于邊框的有無,offset獲取的是整個元素的寬度包括邊框和內(nèi)邊距,而style.width獲取的是元素內(nèi)容的寬度 就是樣式表設(shè)置的width。