JSFiddle - React, Tailwind, and code Playground

by Anand Rathod

HTML

<script src="http://code.jquery.com/ui/1.8.22/jquery-ui.min.js"></script>
<p>1 and 3 cannot be swapped to the other lists</p>
<ul id="list1">
    <li>One (a)</li>
    <li>Two (a)</li>
    <li class="number">3</li>
</ul>
<ul id="list2">
    <li class="number">1</li>
    <li>Two (b)</li>
    <li>Three (b)</li>
</ul>

CSS

body
{
    font-family: Arial, Tahoma, San-Serif;
    font-size: 11px;
}
p
{
    margin: 0 0 20px;
}
ul
{
    float: left;
    margin: 0 20px 0 0;
    width: 100px;
}
li
{
    background: #fff;
    border: solid 1px #ccc;
    padding: 10px;
}

JavaScript

$(function() {
    $('ul').sortable({
        connectWith: 'ul',
        beforeStop: function(ev, ui) {
            if ($(ui.item).hasClass('number') && $(ui.placeholder).parent()[0] != this) {
                $(this).sortable('cancel');
            }
        }
    });        
});