How to horizontally sort divs using Sortable in JQuery

Posted by Tahir Akram on Stack Overflow See other posts from Stack Overflow or by Tahir Akram
Published on 2010-03-30T09:37:09Z Indexed on 2010/03/30 10:23 UTC
Read the original article Hit count: 499

I am looking to sort my divs horizontally in a container div. I found an example on JQuery website but that is vertical sorting. I want it horizontal.

I want to do it sorting in #sortable Div.

Will you please guide me how can I convert this vertical sorting in horizontal manner.

CSS

<style type="text/css">
    #draggable1 { width: 150px; height: 35px; padding: 0.5em; }
    #draggable2 { width: 150px; height: 35px; padding: 0.5em; }
    #draggable3 { width: 150px; height: 35px; padding: 0.5em; }

    #sortable { width: 700px; height: 35px; padding: 0.5em; }
</style>

JavaScript

<script type="text/javascript">
    $(function() {  
        $("#sortable").sortable({
            revert: true
        }); 
    });
</script>

HTML

<div class="demo">
    <div id="sortable" class="ui-state-default">
        <div id = "draggable1" class="ui-state-default">Home</div>
        <div id = "draggable2" class="ui-state-default">Contact Us</div>
        <div id = "draggable3" class="ui-state-default">FAQs</div>
    </div>
</div>

Screenshot alt text

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ui