Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jquery textarea autosize

$("textarea").keyup(function(e) {
    while($(this).outerHeight() < this.scrollHeight + parseFloat($(this).css("borderTopWidth")) + parseFloat($(this).css("borderBottomWidth"))) {
        $(this).height($(this).height()+1);
    };
});
Comment

javascript textarea autosize

function addAutoResize() {
  document.querySelectorAll('[data-autoresize]').forEach(function (element) {
    element.style.boxSizing = 'border-box';
    var offset = element.offsetHeight - element.clientHeight;
    element.addEventListener('input', function (event) {
      event.target.style.height = 'auto';
      event.target.style.height = event.target.scrollHeight + offset + 'px';
    });
    element.removeAttribute('data-autoresize');
  });
}
Comment

autosize a textarea using Prototype

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <script src="http://www.google.com/jsapi"></script>
        <script language="javascript">
            google.load('prototype', '1.6.0.2');
        </script>
    </head>

    <body>
        <textarea id="text-area" rows="1" cols="50"></textarea>

        <script type="text/javascript" language="javascript">
            resizeIt = function() {
              var str = $('text-area').value;
              var cols = $('text-area').cols;

              var linecount = 0;
              $A(str.split("
")).each( function(l) {
                  linecount += Math.ceil( l.length / cols ); // Take into account long lines
              })
              $('text-area').rows = linecount + 1;
            };

            // You could attach to keyUp, etc. if keydown doesn't work
            Event.observe('text-area', 'keydown', resizeIt );

            resizeIt(); //Initial on load
        </script>
    </body>
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: react router dom change default path 
Javascript :: MAC addresses in JavaScript 
Javascript :: merge sort algorithm in javascript 
Javascript :: install three js fiber 
Javascript :: array cut only last 5 element 
Javascript :: vue access computed property in data 
Javascript :: open link in new tab javascript 
Javascript :: declare an array nodejs 
Javascript :: node.js copy to clipboard 
Javascript :: next day date javascript 
Javascript :: react hook form validation 
Javascript :: javascript sleep 1 second” is a pretty common code problem that people search ;-) 
Javascript :: secure random nodejs 
Javascript :: Lodash.chunk chunk 
Javascript :: array put value in index 
Javascript :: how to print console in javascript 
Javascript :: react app 
Javascript :: json server paging 
Javascript :: react bootstrap cdn 
Javascript :: react router cannot read location of undefined 
Javascript :: insert element after element javascript 
Javascript :: how to add element in arry in js 
Javascript :: clean collection mongoose 
Javascript :: bracket notation javascript 
Javascript :: javascript online test 
Javascript :: javascript is int 
Javascript :: javascript random 1 or 0 
Javascript :: extend javascript 
Javascript :: generate uuid from string js 
Javascript :: react tooltip on disabled button 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =