Skip to content

Instantly share code, notes, and snippets.

@lyonsun
Created October 28, 2015 21:12
Show Gist options
  • Select an option

  • Save lyonsun/8ed7d542f7ccd69312cd to your computer and use it in GitHub Desktop.

Select an option

Save lyonsun/8ed7d542f7ccd69312cd to your computer and use it in GitHub Desktop.

Revisions

  1. lyonsun created this gist Oct 28, 2015.
    12 changes: 12 additions & 0 deletions select2_select_all.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    // credits: http://jsfiddle.net/jeadr/62/

    $("#e1").select2();
    $("#checkbox").click(function(){
    if($("#checkbox").is(':checked') ){
    $("#e1 > option").prop("selected","selected");
    $("#e1").trigger("change");
    }else{
    $("#e1 > option").removeAttr("selected");
    $("#e1").trigger("change");
    }
    });