Give this a try for a whimsical experience involving dragging and the div
element:
HTML Code
<div id="d2" class="ui-widget-content" contenteditable>
I look like textarea :)
</div>
CSS Code
#d2{
-moz-appearance: textfield;
-webkit-appearance: textfield;
background-color: white;
background-color: -moz-field;
border: 1px solid darkgray;
box-shadow: 1px 1px 1px 0 lightgray inset;
font: -moz-field;
font: -webkit-small-control;
margin-top: 5px;
padding: 2px 3px;
width: 300px;
height: 200px;
}
JQuery Code
$(function() {
$( "#d2" ).draggable({revert: function(obj){
if (obj === true) {
// success
return false;
}
else {
// reverting
var offset = $(this).offset();
var xPos = offset.left;
var yPos = offset.top;
$("#d2").css("width", $("#d2").width()+xPos);
$("#d2").css("height", $("#d2").height()+yPos );
return true;
}
}});
});
This code allows you to drag and resize a div element to mimic a textarea, offering a unique approach.
Check out the code in action on JSFiddle!