Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
-6
rated 0 times [  1] [ 7]  / answers: 1 / hits: 40026  / 12 Years ago, fri, june 8, 2012, 12:00:00

Possible Duplicate:

Detecting presence of a scroll bar in a DIV using jQuery?






There is markup as below,



<div class=content>Lorem</div>
<div class=content>Lorem Iorem Lorem Iorem Lorem Iorem Lorem Iorem Lorem IoremLorem Iorem Lorem Iorem Lorem Iorem</div>
<div class=content>Lorem</div>
<div class=content>Lorem</div>


If content have scroll bar, then it should add class to that div like scroll-image.



Height can be different for DIVs. Any jQuery solution for this.


More From » jquery

 Answers
1
(function($) {
$.fn.hasScrollBar = function() {
return this.get(0).scrollHeight > this.height();
}
})(jQuery);

$('#my_div1').hasScrollBar(); // returns true if there's a `vertical` scrollbar, false otherwise..


Taken from How can I check if a scrollbar is visible?


[#85055] Thursday, June 7, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
parker

Total Points: 259
Total Questions: 109
Total Answers: 97

Location: Zambia
Member since Thu, Jun 25, 2020
4 Years ago
;