2014-07-04 28 views
0
$("#grouptree").treeview({ 
      animated: "fast", 
     collapsed: true, 
     unique: true, 
     persist: "cookie", 
     toggle: function() { 
      window.console && console.log("%o was toggled", this); 
     } 
    }); 

上面的代碼是我的樹視圖代碼, 每一個複選框具有類=「treecheck」,允許用戶從樹狀檢查從樹狀只有一個複選框

只檢查一個複選框
+0

什麼d你的意思是我只想選擇一個?從treeview中的 –

+0

只允許檢查一個複選框 –

回答

1

,你必須寫上更改事件類treecheck,並且每當更改一個時,取消選中此類名稱。

你可以使用not()這樣:

HTML:

<input type="checkbox" class="treecheck"/> 
<input type="checkbox" class="treecheck"/> 
<input type="checkbox" class="treecheck"/> 
<input type="checkbox" class="treecheck"/> 
<input type="checkbox" class="treecheck"/> 

JQUERY:

$('.treecheck').on('change', function() { 
    $('.treecheck').not(this).prop('checked', false); 
}); 

FIDDLE

FIDDLE DEMO