目前我有一个带有文本的可排序元素列表:
如何将其更改为带有标签且代码更改最少的复选框列表?
当前代码:
<div class='left'>
<ul id="sortable">
<li class="ui-state-highlight"></li>
<li class="ui-state-highlight"></li>
<li class="ui-state-highlight"></li>
</ul>
</div>
脚本
<script>
$(function() {
$( "#sortable" ).sortable({
items: "li:not(.ui-state-highlight)",
placeholder: "ui-state-highlight"
});
$( "#sortable" ).disableSelection();
});
</script>
Javascript
var nodes = document.getElementById('sortable').getElementsByClassName('ui-state-highlight');
if (nodes.length > 0)
{
nodes[0].innerHTML = getSymbol();
nodes[0].setAttribute("class", "ui-state-default");
}