Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. How to make the text box draggable using jQuery?

How to make the text box draggable using jQuery?

Scheduled Pinned Locked Moved JavaScript
javascripthtmldesigntutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tesic Goran
    wrote on last edited by
    #1

    Is anybody there who has experience with making html input text box draggable using jQuery? I've tried to wrap text box inside div and can make it resizable, but not draggable. The div and text box are placed on standard jQuery UI dialog. Actually, I need both - draggable and resizable html input text box inside dialog. The code is as follows:

    $(document).ready(function() {
        $("#btnShow").click(function(e) {
            $('#dialog').dialog("open");
        });
        $('#dialog').dialog({
            title: "Sample dialog",
            resizable: false,
            autoOpen: false,
            width: 400,
            height: 300,
            buttons: \[{ text: "OK", click: function() { /\* do something \*/ } },
                { text: "Cancel", click: function() { $(this).dialog("close") } }\]
        });
        $('#divText1').draggable({
            containment: "parent",
            cursor: "move"
        }).resizable({
            containment: "parent",
            handles: "e, w"
        });
    });
    
    <input id="btnShow" type="button" value="Show" />
    
    
    
        
    
            <input type="text" style="width: 98%;" value="Hello world!" />  
    

    Thank you in advance. Goran

    V Z 2 Replies Last reply
    0
    • T Tesic Goran

      Is anybody there who has experience with making html input text box draggable using jQuery? I've tried to wrap text box inside div and can make it resizable, but not draggable. The div and text box are placed on standard jQuery UI dialog. Actually, I need both - draggable and resizable html input text box inside dialog. The code is as follows:

      $(document).ready(function() {
          $("#btnShow").click(function(e) {
              $('#dialog').dialog("open");
          });
          $('#dialog').dialog({
              title: "Sample dialog",
              resizable: false,
              autoOpen: false,
              width: 400,
              height: 300,
              buttons: \[{ text: "OK", click: function() { /\* do something \*/ } },
                  { text: "Cancel", click: function() { $(this).dialog("close") } }\]
          });
          $('#divText1').draggable({
              containment: "parent",
              cursor: "move"
          }).resizable({
              containment: "parent",
              handles: "e, w"
          });
      });
      
      <input id="btnShow" type="button" value="Show" />
      
      
      
          
      
              <input type="text" style="width: 98%;" value="Hello world!" />  
      

      Thank you in advance. Goran

      V Offline
      V Offline
      Vitaly Tomilov
      wrote on last edited by
      #2

      http://jqueryui.com/demos/draggable/[^]

      1 Reply Last reply
      0
      • T Tesic Goran

        Is anybody there who has experience with making html input text box draggable using jQuery? I've tried to wrap text box inside div and can make it resizable, but not draggable. The div and text box are placed on standard jQuery UI dialog. Actually, I need both - draggable and resizable html input text box inside dialog. The code is as follows:

        $(document).ready(function() {
            $("#btnShow").click(function(e) {
                $('#dialog').dialog("open");
            });
            $('#dialog').dialog({
                title: "Sample dialog",
                resizable: false,
                autoOpen: false,
                width: 400,
                height: 300,
                buttons: \[{ text: "OK", click: function() { /\* do something \*/ } },
                    { text: "Cancel", click: function() { $(this).dialog("close") } }\]
            });
            $('#divText1').draggable({
                containment: "parent",
                cursor: "move"
            }).resizable({
                containment: "parent",
                handles: "e, w"
            });
        });
        
        <input id="btnShow" type="button" value="Show" />
        
        
        
            
        
                <input type="text" style="width: 98%;" value="Hello world!" />  
        

        Thank you in advance. Goran

        Z Offline
        Z Offline
        ZurdoDev
        wrote on last edited by
        #3

        I haven't tested it but I believe the problem you are likely running into is that the textbox has input area so if you click that area and try to drag, you are in control of the textbox not the div. You need an element that you can drag, maybe put an image to the left of the textbox or something like that. But trying to drag inside a textbox will just highlight the text.

        There are only 10 types of people in the world, those who understand binary and those who don't.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups