[技術討論] optgroup check all

http://jsfiddle.net/NWDC8/161/
請問ching
我想選任何option唔要select all點改啊
many thanks

本帖最後由 justiceice 於 2018-7-4 15:44 編輯

del, 試咗唔 work (原 post: 加 disabled)

TOP

請問ching
我想選任何option唔要select all點改啊
many thanks
carlkyo 發表於 2018-7-4 15:09

唔明你想點, 係咪咁

    $(document).ready(function(){
     $("optgroup").on("click", function() {
    $(this).next().children("option").removeAttr("selected");
    $(this).prev().children("option").removeAttr("selected");
});
});

TOP

$(document).ready(function(){
     $("optgroup").on("click", function() {
   // $(this).children("option").prop("selected", "selected");
    $(this).next().children("option").prop("selected", false);
    $(this).prev().children("option").prop("selected", false);
});
});

TOP

我想做到禁optgroup 可以全選optgroup 內既選項
而禁單一選項唔會
依家做唔到單一選項

TOP

退而求其次, 用Double Click 選全Group:

$(document).ready(function(){
  $("optgroup").on("dblclick", function() {
    $(this).children("option").prop("selected", "selected");
    $(this).next().children("option").prop("selected", false);
    $(this).prev().children("option").prop("selected", false);
  });
});

TOP

$("option").on("click", function() {
    event.stopPropagation();
  });

TOP

退而求其次, 用Double Click 選全Group:

$(document).ready(function(){
  $("optgroup").on("dblclick",  ...
clio 發表於 2018-7-9 13:17

Many thanks
未諗到呢招

TOP

$("option").on("click", function() {
    event.stopPropagation();
  });
ThomasYau 發表於 2018-7-9 15:28
thanks

TOP

本帖最後由 carlkyo 於 2018-7-10 18:19 編輯

我再試試

TOP