这就是我在jQuery中用可选择创建项目的方法 isValid = new Array(list.size);
var div = document.getElementById("selectable");
for(i=0; i<list.size; i++)
{
// It should look like that//<li class="ui-widget-content">Item 1</li>
var properties = list[i].getProperties();
var aTag = document.createElement("li"); //file name or something as ID
aTag.setAttribute('class',"ui-widget-content");
aTag.setAttribute('id',i);
aTag.innerHTML = properties.fileName; //file name
div.appendChild(aTag);
}
我尝试了以下两种,但它们都不起作用:
$(function () {
$("#selectable").selectable();
});
$("#selectable").selectable({
selected: function (event, ui) {
var x = 0;
x++;
}
});
应填写的HTML部分
<div class="demo">
<ol id="selectable">
</ol>
</div>
我错过了什么吗?谢谢!
答案 0 :(得分:0)
那个人工作了!
$(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));
$("#play").button("option", {
label: "pause",
icons: {
primary: "ui-icon-pause"
}
});
});
}
});
});