Using jquery ui draggable
plugin, I've made html text box draggable in this way:
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$("#Text1").draggable({
containment: "parent",
cancel: null
});
});
</script>
<form id="form1" runat="server">
<div>
<div id="dialog" title="Dialog Box" style="border: solid 1px black;">
<input id="Text1" type="text" style="width: 200px; height: 20px;" value="Text1" />
</div>
</div>
</form>
But, how to make it resizable using jQuery as well?
Thank you in advance.
Goran
jQuery UI draggable() method is used to make any DOM element draggable. Once the element is made draggable, you can move it by clicking on it with the mouse and drag it anywhere within the viewport.
To make an object draggable set draggable=true on that element. Just about anything can be drag-enabled: images, files, links, files, or any markup on your page.
Using jQuery UI, we can make the DOM(Document Object Model) elements to drag anywhere within the view port. This can be done by clicking on the draggable object by mouse and dragging it anywhere within the view port. If the value of this option is set to false, it will prevent the DOM elements to be dragged .
Check whether your draggable object is already loaded in the viewport. If it is not, it won't work properly. JUST AFTER the draggable object to be absolutely sure that everything is loaded at the correct time. When you'll be sure everything is ok, then you'll be able to refactor.
Here is the DEMO to make the HTML textbox resizable
and draggable
using jquery-ui
HTML:
<div id="container" class="ui-widget-content">
<h3 class="ui-widget-header">Containment</h3>
<span id="draggable">*
<input type="text "id="resizable" class="ui-state-active" value="This is input box">
</span>
</div>
JS:
$(function() {
$( "#resizable" ).resizable({
containment: "#container"
});
$( "#draggable" ).draggable({containment: "#container"});
});
By using jQuery UI
.
HTML FILE<input type="text" id="resizable" />
JavaScript File
reference all needed jQuery files in script tag i.e
<script src="*all needed .js files*"></script>
<script>
$(function() {
$( "#resizable" ).resizable();
});
</script>
by the way why u need to make textbox resizable
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