Search code examples
javascriptjqueryhtmlajaxzk

Onclick 1st Div goes last in the list?


I create collapsible tab and I want some changes is there if once click on 1st tab this will be goes last in the collapsible list and same for the other tab also. (If having 4 tab and click on 1st tab in the list 1st is goes last 2 3 4 1)

Thanks in advances...


Solution

  • I think you are looking for this.

    HTML code

    <div class="wrapper">
    <div>div 1</div>
    <div>div 2</div>
    <div>div 3</div>
    <div>div 4</div>
    </div>
    

    jQuery Code

    $('.wrapper').find('div').on('click', function(){
        $(this).appendTo( $(this).parent() )
    })
    

    Working Code: http://jsfiddle.net/P7tap/