我想通过点击其他元素来取消选择选定的li。例如:
<style>
#feedback { font-size: 1.4em; }
#selectable .ui-selecting { background: #FECA40; }
#selectable .ui-selected { background: #F39814; color: white; }
#selectable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
#selectable li { margin: 3px; padding: 0.4em; font-size: 1.4em; height: 18px; }
</style>
<script>
$(function() {
$( "#selectable" ).selectable();
});
</script>
<div class="demo">
<ol id="selectable">
<li class="ui-widget-content"><a href="">link can not click</a></li>
<li class="ui-widget-content">Item 2</li>
<li class="ui-widget-content">Item 3</li>
<li class="ui-widget-content">Item 4</li>
<li class="ui-widget-content">Item 5</li>
<li class="ui-widget-content">Item 6</li>
<li class="ui-widget-content">Item 7</li>
</ol>
<a href="">click me to unselected</a>
</div><!-- End demo -->
非常感谢!!
答案 0 :(得分:0)
只是removing the class似乎工作正常(来自我之前提问的jsfiddle):
<a href="#" id="unselect">click me to unselected</a>
然后:
$('#unselect').click(function(event) {
$('#selectable>li').removeClass('ui-selected');
});