My current script is toggling between disabled and enabled.

```
<script>
    $("#filter").attr('checked', !$("#mylist")[0].disabled);
    $("#filter").click(function() {
        $("#mylist").attr('disabled', !this.checked)
    });
</script>

```

and my html code is:

```
<div>
    <div class="checkbox">
        <input type="checkbox" checked="checked" id="filter" />
        <label for="filter">Types</label>
        <br>
    </div>
    <select class="selectpicker" id="mylist" multiple>
        <option>A</option>
        <option>B</option>
        <option>C</option>
    </select>
</div>

```

by default the checkbox is checked, and when I remove the `checked="checked" , it doesn't work at all.  

How can I disable this by default and only enable/disable it afterwards?