I was wondering if anybody knows how I would go about detecting when the scrollbar appears inside a textarea.
I am currently using mootools for my JavaScript and I am having issues getting it to detect a scrollbar.
function has_scrollbar(elem_id) {     const elem = document.getElementById(elem_id);     if (elem.clientHeight < elem.scrollHeight)         alert("The element has a vertical scrollbar!");     else         alert("The element doesn't have a vertical scrollbar."); }   See this jsFiddle http://jsfiddle.net/qKNXH/
I made a jQuery "compatible" version of Tommaso Taruffis code
function resize_until_scrollbar_is_gone(selector) {      $.each($(selector), function(i, elem) {         while (elem.clientHeight < elem.scrollHeight) {             $(elem).height($(elem).height()+5);         }     }); }   It can handle multiple elements and accepts: selectors, jQuery objects, or DOM elements.
It can be called like this:
resize_until_scrollbar_is_gone('textarea'); 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With