Is it possible to determine if a UI.Layout pane has a scrollbar? My center pane has DIVs; one of the DIVs contains a jqGrid that I'm trying to auto resize. Playing around with resize events, the grid resizes properly if there is no scrollbar. I believe if I could determine whether or not a scrollbar is there, I can better resize the g开发者_如何学Crid.
Thank You
Well you can create a new function like this to check for the existance of a scrollbar
$.fn.hasVerticalScrollBar = function () {
if (this[0].clientHeight < this[0].scrollHeight) {
return true
} else {
return false
}
}
$.fn.hasHorizontalScrollBar = function() {
if (this[0].clientWidth < this[0].scrollWidth) {
return true
} else {
return false
}
}
Usage:
alert($('#mydivid').hasHorizontalScrollBar());
alert($('#mydivid').hasVerticalScrollBar());
精彩评论