• Parent1
      child1
  • Parent2
      child2
      child2.1
    • Parent1
        child1
    • Parent2
        child2
        child2.1
      • Parent1
          child1
      • Parent2
          child2
          child2.1
      • DEVHIDE
        • Home (current)
        • About
        • Contact
        • Cookie
        • Home (current)
        • About
        • Contact
        • Cookie
        • Disclaimer
        • Privacy
        • TOS
        Login Or Sign up

        how to drag only child elements inside nested ul tags using jquery ui draggable

        1.4k Views Asked by Sukanya Moorthy At 30 December 2013 at 06:34 2025-12-12T05:10:36.857000
        My list is something like this
        <div id="jqxTree">
            <ul>
                <li>Parent1
                    <ul>
                        child1
                    </ul>
                </li>
                <li>Parent2
                    <ul>
                        child2
                    </ul>
                    <ul>
                        child2.1
                    </ul>
                </li>
            </ul>
        </div>
        

        when i use jquery draggable its dragging entire list.How to i drag only child1,child2,child2.1 elements .To generalise i wanna drag only li elements inside ul which is inside li..

        I tried using the below function but on mouseover the elements of li the elemnts get hidden

        $('#jqxTree').delegate('li li', 'mouseover', function () {
            $(this).draggable({
                revert: true,
                revertDuration: 0
            });
        }); 
        
        jquery jquery-draggable jquery-droppable
        Original Q&A
        1

        There are 1 best solutions below

        1
        Deryck Deryck On 30 December 2013 at 06:43 BEST ANSWER

        According to jQuery API page:

        As of jQuery 1.7, .delegate() has been superseded by the .on() method.

        Fiddle Demo

        jQuery:

        $(function () {
            $('#jqxTree').on('mouseenter mouseover', 'li > ul', function () {
                $(this).draggable({
                    revert: true,
                    revertDuration: 0
                });
        
            });
        });
        

        In CSS, use > between parent and child elements.

        Also you had li li instead of li ul.

        Related Questions in JQUERY

        • How to sort these using Javascript or Jquery Most effectively
        • Ajax jQuery firing multiple time display event for the same result
        • .hover() seems to overwrite .click()
        • Check for numeric value with optional commas javascript
        • Extending Highmaps Side Effect
        • Array appending after each onclick and loop in javascript
        • how can i append part of a table based on how many tr it has?
        • Play multiple audio files in a slider
        • Remove added set of rows
        • Access property of an object of type [Model] in JQuery
        • AJAX PHP - Reload div after submit
        • proengsoft/laravel-jsvalidation ReferenceError: jQuery is not defined
        • when a checkbox is checked how to display a different hidden element using javascript
        • Get jquery error Uncaught RangeError: Maximum call stack size exceeded
        • Removing only the closest thead on table filtering

        Related Questions in JQUERY-DRAGGABLE

        • jsPlumb Draggable with Container Element - How to setup?
        • event.preventDefault() not preventing normal <a> action
        • Is there anyway to change the text/icon that is shown when dragging an image?
        • how to adjust div width based on other div postion
        • append draggable image to a div for print
        • Append draggable image into specific div
        • jQuery-ui-draggable-collision not working with jQuery-ui 1.11.2
        • Drag and drop and scale images but user's upload pic isn't draggable and resizable
        • Multiple Draggables Find the X and Y Positions
        • how to disguise the droppable shopping cart if parents div are different and how to drop element as per parent element?
        • Wrapping DIVs with inline-block
        • Passing image thumbnail and related text to droppable JQuery UI
        • Getting jQuery draggable to snap to specific grid
        • Jquery Image not visibly dragging after first drop
        • jQuery Draggable Getting Negative Position Value When Dragged

        Related Questions in JQUERY-DROPPABLE

        • how to disguise the droppable shopping cart if parents div are different and how to drop element as per parent element?
        • Jquery Image not visibly dragging after first drop
        • Jquery-ui. Trouble using "draggable", "sortable", and "tabs" together
        • Is there a way to drag a row from a JQGrid to a droppable textfield using the gridDnD plugin?
        • JQuery Dragable on button, helper option not working
        • how to drag only child elements inside nested ul tags using jquery ui draggable
        • drag and drop inside nested Divs
        • jQuery Sortable how to set all children as a drop target
        • Drop() gets called twice with Sortable/Droppable
        • JQuery UI: Cancel Sortable upon Droppable Drop
        • Non moving droppables in a jquery sortable
        • jquery drop div on multiple droppable tds but use only highest
        • Jquery Droppable Drop an item not at last
        • jQuery draggable dropped on 2 droppables. only need one
        • Alert trigger after multiple drop events

        Trending Questions

        • UIImageView Frame Doesn't Reflect Constraints
        • Is it possible to use adb commands to click on a view by finding its ID?
        • How to create a new web character symbol recognizable by html/javascript?
        • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
        • Heap Gives Page Fault
        • Connect ffmpeg to Visual Studio 2008
        • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
        • How to avoid default initialization of objects in std::vector?
        • second argument of the command line arguments in a format other than char** argv or char* argv[]
        • How to improve efficiency of algorithm which generates next lexicographic permutation?
        • Navigating to the another actvity app getting crash in android
        • How to read the particular message format in android and store in sqlite database?
        • Resetting inventory status after order is cancelled
        • Efficiently compute powers of X in SSE/AVX
        • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

        Popular # Hahtags

        javascript python java c# php android html jquery c++ css ios sql mysql r reactjs

        Popular Questions

        • How do I undo the most recent local commits in Git?
        • How can I remove a specific item from an array in JavaScript?
        • How do I delete a Git branch locally and remotely?
        • Find all files containing a specific text (string) on Linux?
        • How do I revert a Git repository to a previous commit?
        • How do I create an HTML button that acts like a link?
        • How do I check out a remote Git branch?
        • How do I force "git pull" to overwrite local files?
        • How do I list all files of a directory?
        • How to check whether a string contains a substring in JavaScript?
        • How do I redirect to another webpage?
        • How can I iterate over rows in a Pandas DataFrame?
        • How do I convert a String to an int in Java?
        • Does Python have a string 'contains' substring method?
        • How do I check if a string contains a specific word?
        .

        Copyright © 2021 Jogjafile Inc.

        • Disclaimer
        • Privacy
        • TOS
        • Homegardensmart
        • Math
        • Aftereffectstemplates