我正在尝试添加6个可选行的限制,但我无法使其工作。任何帮助!!
<script>
$(function() {
$(".selectable").selectable({
filter: "td.cs",
stop: function() {
var result = $("#select-result").empty();
var result2 = $("#result2");
$(".ui-selected", this).each(function() {
var cabbage = this.id + ', ';
result.append(cabbage);
});
var newInputResult = $('#select-result').text();
newInputResult = newInputResult.substring(0, newInputResult.length - 1);
result2.val(newInputResult);
}
});
});
</script>
提前致谢!!!
答案 0 :(得分:4)
您可以使用selecting
事件回调执行此操作,如下所示
$( "#selectable" ).selectable({
selecting: function(event, ui) {
if ($(".ui-selected, .ui-selecting").length > 6) {
$(ui.selecting).removeClass("ui-selecting");
}
}
});