大佬教程收集整理的这篇文章主要介绍了jquery-ui – 如何禁用可选列表的特定元素,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
$('#disableButton').click(function(){ $('#selectable li#b ').selectable('disable'); });
http://jsfiddle.net/Komlan/RYWaZ/1/
这是我的代码
//reset seats function resetSelect(){ var options = { filter: "li.selectable" }; $( "#selectable").selectable(options); } //Ajax get taken seats $('input[name="choice"]').change(function(){ resetSelect(); var sc_id = $('input:radio[name=choice]:checked').val(); $.ajax({ url: 'seatings.PHP',data:{ sc_id:sc_id},type: "POST",dataType:'text',success: function(data){ var id = data.split(","); for (var i=0;i<id.length -1;i++){ alert(id[i]); var string = "#"+id[i]; $(string).css("color","red"); $('#selectable li'+string).removeClass("selectable ui-selected"); } var options = { filter: "li.selectable" }; $( "#selectable" ).selectable('destroy').selectable(options); } }); });
总而言之,每次我的单选按钮组发生更改时,我都会获得一系列id并逐个禁用它们.
添加css类“selectable”(或任何你想要的):
<ol id="selectable"> <li class="ui-widget-content selectable" id="ok"> 1</li> <li class="ui-widget-content selectable"> 2</li> <li class="ui-widget-content selectable"> 3</li> <li class="ui-widget-content selectable"> 4</li> <li class="ui-widget-content selectable"> 5</li> <li class="ui-widget-content selectable"> 6</li> <li class="ui-widget-content selectable"> 7</li> </ol>
然后在该css类上使用filter:
// Create a filter to only make <li> with the specified css class,selectable. var options = { filter: "li.selectable" }; $( "#selectable" ).selectable(options); $('#lol').click(function(){ console.log('dsfds'); // Remove/add (toggle) the class used in the filter on the <li> you want to remove the selectable. // (Also remove the ui-selected in case it's selected.) $('#selectable li#ok').toggleClass("selectable").removeClass("ui-selected"); // Now destroy the selectable and re-create it with the filter again. // We removed the css class from a <li> used in the filter,so it won't be selectable again. $( "#selectable" ).selectable('destroy').selectable(options); });
更新:http://jsfiddle.net/RYWaZ/7/
参考文献:
以上是大佬教程为你收集整理的jquery-ui – 如何禁用可选列表的特定元素全部内容,希望文章能够帮你解决jquery-ui – 如何禁用可选列表的特定元素所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。