Skip to content

Instantly share code, notes, and snippets.

@xyzdata
Last active October 31, 2017 06:07
Show Gist options
  • Save xyzdata/50d9af7fe5749fe199146e4e5e2f3f1e to your computer and use it in GitHub Desktop.
Save xyzdata/50d9af7fe5749fe199146e4e5e2f3f1e to your computer and use it in GitHub Desktop.
how to dynamically generate nested li list using js

how to dynamically generate nested li list using js

    
//

https://stackoverflow.com/questions/19363972/create-nested-lists-from-a-dynamically-created-single-list

jquery wrap & wrapall & wrapinner

https://api.jquery.com/wrap/

https://api.jquery.com/wrapall/

https://api.jquery.com/wrapinner/

Wrap an HTML structure around each element in the set of matched elements.

在一组匹配的元素中的每个元素周围包装一个HTML结构。

<div class="container">
    <div class="inner">Hello</div>
    <div class="inner">Goodbye</div>
</div>

.wrap( wrappingElement )

$( ".inner" ).wrap( "<div class='new'></div>" );
<div class="container">
    <div class="new">
        <div class="inner">Hello</div>
    </div>
    <div class="new">
        <div class="inner">Goodbye</div>
    </div>
</div>

.wrap( function )

$( ".inner" ).wrap(function() {
    return "<div class='" + $( this ).text() + "'></div>";
});
<div class="container">
    <div class="Hello">
        <div class="inner">Hello</div>
    </div>
    <div class="Goodbye">
        <div class="inner">Goodbye</div>
    </div>
</div>
@xyzdata
Copy link
Author

xyzdata commented Jun 27, 2017

@xyzdata
Copy link
Author

xyzdata commented Jun 27, 2017

@xgqfrms-GitHub
Copy link

@xgqfrms-GitHub
Copy link

@xyzdata
Copy link
Author

xyzdata commented Oct 31, 2017

native JS sort div !

https://gist.github.com/xgqfrms-GitHub/e3915ad946c6008e6a0d4d7335ae3112#gistcomment-2243564

RAIO/HTML5-Drag-Drop/F9-v2.0.0-modules/fast-preview/sortable.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment