How to pick up multiple items and play in a single item?

2

Hello, I wanted to know how I can get these li's all and put only the first <ul> .

<ul>
    <li>1 </li>
    <li>2 </li>
    <li>3</li>
    <li>4 </li>
</ul>

<ul>
    <li>5 </li>
    <li>6 </li>
    <li>7 </li>
    <li>8 </li>
</ul>

<ul>
    <li>9 </li>
    <li>10</li>
</ul>
    
asked by anonymous 23.05.2016 / 17:44

2 answers

4

You can do this:

$('li').appendTo('ul:first');

In this way you leave the other ul empty.

Example: link

    
23.05.2016 / 17:55
3

$('li').each(function(){
        $('.nova-ul').append($(this));
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><ul><li>1</li><li>2</li><li>3</li><li>4</li></ul><ul><li>5</li><li>6</li><li>7</li><li>8</li></ul><ul><li>9</li><li>10</li></ul><ulclass="nova-ul"></ul>

But, as @Sergio asked, and if you want to delete the% of original% you will have to add <ul> after $('ul').not('.nova-ul').remove();

    
23.05.2016 / 17:50