I’m designing a vertical scroll-bar plugin for jquery. my plugin accepts a height value as option and if the div height exceeds the given height the scroll-bar will be visible. now the problem is I need to get the real height of the div content.
<div id="scroll">
Contents Here
</div>
jquery:
$.fn.vscrollbar = function (options) {
.
.
.
var contentHeight=this.contents().height() //that is not working correctly
if(contentHeight > options.height){
this.css({overflow : 'hidden'}).height(options.height);
}
.
.
.
})(jQuery);
I can get the height of div before applying ‘overflow:hidden’ but the problem is I want this to work even if it has overflow:hidden style from the begining.
You should have a hidden
divon the page, of the samewidthbutoverflow auto. As soon as your plugin is called/instantiated, take the height of that hiddendivand do what you want.