Remove <option> by .class AND when custom attribute NOT equal to x.

Not working. Need to be forked.

by clarusdignus

HTML

<select name="myselect_a">
    <option selected="selected"></option>
    <option value="Apply filter">Apply filter</option>    
</select>

<select name="myselect_b">
    <option selected="selected"></option>
    <option data-customattribute="58" value="1" class="filterable_option">Dog</option>    
    <option data-customattribute="58" value="2" class="filterable_option">Cat</option>
    <option data-customattribute="60" value="3" class="filterable_option">Parrot</option>
    <option>I have no class or custom attribute.</option>
</select>

JavaScript

$('select[name=myselect_a]').on('change', function() {
    var $myselect_a_option = $("select[name=myselect_a]").val();
    if($myselect_a_option === 'Apply filter'){	
        var $some_value = '58';
        $("select[name=myselect_b] option.filterable_option[data-customattribute!=" + $some_value + "]").remove();
    }
});