Move DOM element to top of the parent and after selected element

Susantha7
<ul class="level1">
    <li>
         <span>category name</span>
         <ul class="level2"></ul>
         <ul class="level2"></ul>
         <ul class="level2"></ul>
         <ul class="level2"></ul>
         <ul class="level2"></ul>
    <li>
</ul>

I want selected ul that is with level2 class to move to top of the ul.level1 li but it should be after ul.level1 li span.

Actually this is regarding move elements in bootstrap tree http://jsfiddle.net/umutc1/eyf9q87c/

Andrew Hewitt

See this JSFiddle, think it's what you're after: JSFiddle

Essentially, you hook onto the event that triggers the move, find the thing you want to move, find where you want to move it to and use the .after() jq function to do the move.

HTH

$(function(){
    $("ul.level2").click(function(e){
        var clickedUL = $(e.target).closest("UL");
        $("ul > li > span").after(clickedUL);
    });
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

new added element in the top of JList is automatically selected

From Dev

Is there a way to move an element outside of its parent with jquery?

From Dev

Move selection after a DOM element

From Dev

Is it possible to move a <video> element in the DOM without resetting it?

From Dev

element on top of parent's sibling

From Dev

insert element after selected node

From Dev

AngularJS: Add a loader element to top of DOM

From Dev

Move DOM element to top of the parent and after selected element

From Dev

Stick div to top of parent element

From Dev

Want to move an added element to a different part of the DOM

From Dev

CSS :after behind parent element

From Dev

How To Move A DIV Element A Little Towards The Top

From Dev

Remove element from selected list not from dom

From Dev

Move selected element to the end

From Dev

How to move to the top of the element?

From Dev

Select the next DOM element after the current element

From Dev

jQuery move element up to parent level

From Dev

add element to the DOM after load()

From Dev

How to move element relative to an element on top that varies in height

From Dev

jquery DOM accessing parent element

From Dev

element on top of parent's sibling

From Dev

Scroll parent to top of child element

From Dev

Is there a way in CSS to move an element in the DOM

From Dev

Remove parent DOM element with PHP

From Dev

Getting the element that occupies the top of the parent element

From Dev

Move a DOM element Using jQuery

From Dev

UI element jumps after move

From Dev

Adding an element after another element that has no parent

From Dev

react.js make DOM element available to top parent main component

Related Related

HotTag

Archive