如何在jQuery UI可选择的倍数中追加li元素的id

时间:2011-11-03 00:29:25

标签: jquery user-interface selectable

好的,所以我正在尝试集成jQuery UI插件可选择(网格),我喜欢它如何发布所选索引。这就是我想做的事情:

$(function() {
    $( "#selectable" ).selectable({
        stop: function() {
            var result = $( "#select-result" ).empty();
            $( ".ui-selected").each(function() {
                 var index = $( "#selectable li" ).attr('id');
                                   // But I want the ids of all the selected elements,
                                   // but the id of the first is just getting copied on my site!
                result.append( "#" + ( index + 1 ) );
            });
        }
    });
});

1 个答案:

答案 0 :(得分:0)

尝试:

$(function() {
    $( "#selectable" ).selectable({
        stop: function() {
            var result = $( "#select-result" ).empty();
            $( ".ui-selected").each(function() {
                 var index = $( this ).attr('id'); 
                result.append( "#" + ( index + 1 ) );
            });
        }
    });
});