您可以使用delay和distance選項來避免通過不需要的小鼠標移動來觸發選擇。
延遲:
時間以毫秒爲單位來定義時選擇應該開始。這有助於防止在單擊某個元素時出現不需要的選擇。
距離:
公差,以像素爲單位,選擇應該開始時。如果指定,則只有在鼠標拖過指定距離後才能開始選擇。
例如:
$("#selectable").selectable({
delay: 30,
distance: 30
});
#selectable {
list-style: none;
}
#selectable li {
width: 100px;
height: 30px;
}
#selectable .ui-selectee {
background: #ccc;
}
#selectable .ui-selecting {
background: dodgerblue;
}
#selectable .ui-selected {
background: royalblue;
}
<link href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<ul id="selectable">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
</ul>
謝謝,我知道我以前見過的 「距離」 選項,但不知何故,我忽略了它5倍,在API的文檔。 但隨着距離選項的簡單點擊選擇不再工作。 – IARI 2014-11-04 23:03:33