如何取消选择jQuery Selectable中的元素?

时间:2014-07-28 14:21:48

标签: javascript css jquery-ui

如何取消选择jQuery Selectable中的元素?在此Link,有关如何使用jQuery Selectable的详细记录,但从未提及如何再次取消选择所选元素。有什么想法吗?

<script>
$(function() {
    $( "#selectable" ).selectable({
        stop: function() {
            var result = $( "#select-result" ).empty();

            $( ".ui-selected", this ).each(function() {
                var index = $( "#selectable li" ).index( this );
                result.append( " #" + ( index + 1 ) );
            });
        }
    });
});
</script>

<ol id="selectable">
    <?php
        for($i=1;$i<=9;$i++) {
            echo "<li id=\"field_$i\" class=\"ui-state-default\">$i</li>";
        }
    ?>
</ol>

1 个答案:

答案 0 :(得分:1)

按住 ctrl 并单击元素。它也可用于进行多项选择。