所有,我正在尝试实现可选择的图像列表。下面是我所做的。 但我有两个问题需要解决,请帮忙审核一下。谢谢。
- 我不想选择该 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>
最佳答案
我找到了这个。非常容易集成到您的网站上: http://rvera.github.io/image-picker/
关于jquery - jquery ui 中的可选图像项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15238192/