所有,我正在尝试实现可选图像列表。下面是我所做的。但是我有两个问题需要解决,请帮助审查它。谢谢。
- 我不希望选择 img。
- 防止多选。
脚本
function initSelectable() {
$("#layoutol").selectable({
stop : function(event, ui) {
var result = $("#spanSelectedLayout").empty();
$(".ui-selected", this).each(function() {
var index = $("#layoutol li").index(this);
result.append((index + 1));
});
},
selected:function (event,ui){
//prevent the img element selected and multiple selected, the below code not make it .
$(event.target).children('.ui-selected').children('.ui-selected').removeClass('ui-selected');
$(event.target).children('.ui-selected').not(':first').removeClass('ui-selected');
}
});
}
html
<ol id="layoutol">
<li class="ui-state-default"><img alt="" src="img/A.PNG" /></li>
<li class="ui-state-default"><img alt="" src="img/B.PNG" /></li>
<li class="ui-state-default"><img alt="" src="img/C.PNG" /></li>
<li class="ui-state-default"><img alt="" src="img/D.PNG" /></li>
</ol>