Skip to content Skip to sidebar Skip to footer

Javascript/jquery Resize Textarea With Div/"grippie"

I've look at many things covering how to make a 'grippie' that resizes a textarea, and have tried all the code but none was worked. Any help? I'm trying to make it like the one on

Solution 1:

I found out how to do it!! Here is a fiddle with the project. I will continue to update it and make it better!

HTML

<textarea id="textarea"></textarea>
<div id="grippie" draggable="false"></div>

QJuery/JavaScript

var resize = false;
$('#textarea').hover(function(e){
    e.preventDefault();
    resize = false;
});
$('#grippie').mousemove(function(e){
    if(resize == true){
      $('#textarea').height(e.pageY-18);
   }
});
$('#grippie').mousedown(function(e){
    resize = false;
   resize = true;
});
$(window).mouseup(function(e){
   resize = false;
});

CSS

#textarea {
   padding: 2px;
   width: 400px;
   height: 200px;
   min-height: 50px;
   overflow: auto;
   resize: none;
}
#grippie {
   display: block;
   width: 404px;
   height: 5px;
   background-color: #CCC;
   border: 1px solid #888;
   cursor: s-resize;
}

Post a Comment for "Javascript/jquery Resize Textarea With Div/"grippie""