How to make html text box draggable and resizable using jQuery UI plugins?

一笑奈何 提交于 2019-12-10 16:54:25

问题


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


回答1:


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"});
});



回答2:


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



来源:https://stackoverflow.com/questions/10732943/how-to-make-html-text-box-draggable-and-resizable-using-jquery-ui-plugins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!