如何在selectable中选择(突出显示)一项而不点击它(通过代码)?
这样我就给它提供了选择/突出显示哪个框的索引
我像这样动态地创建它们
<div class="demo"> <ol id="selectable"> </ol></div>和
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);
}发布于 2011-04-07 04:41:27
您可以使用eq()选择索引。0表示第一项。
$('item').eq(0).css('background-color','yellow'); //give the first item a yellow background.在http://jsfiddle.net/FKvhG/查看工作示例
发布于 2011-04-07 04:37:18
$('youritem').trigger('click');将会完成这项工作!简单的解决方案。
发布于 2011-04-07 04:38:42
您可以使用focus():$('#element').focus();
https://stackoverflow.com/questions/5572596
复制相似问题