i trying find , hide multiple options in select menu.
here menu
<select class="form-control" name="settingscolumnaggregate" id="settingscolumnaggregate"> <option value="none" selected="">none</option> <option value="sum">sum</option> <option value="avg">avg</option> <option value="count">count distinct</option> <option value="max">max</option> <option value="min">min</option> </select>
i want hide options value in ["sum","ave","max","min"]
here tried
$('#settingscolumnaggregate') .find('option[value="sum"][value="avg"][value="max"][value="min"]') .hide();
but not working.
how can correctly select multiple options list of values? here tried
you have loop through option or use filters()
var arr = ["sum","avg","max","min"]; $('#settingscolumnaggregate option').filter(function(){ return jquery.inarray( this.value, arr ) !== -1 }).hide();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <select class="form-control" name="settingscolumnaggregate" id="settingscolumnaggregate"> <option value="none" selected="">none</option> <option value="sum">sum</option> <option value="avg">avg</option> <option value="count">count distinct</option> <option value="max">max</option> <option value="min">min</option> </select>
or use find
, multiple selector bit messy though , hard read. forgot add ,
in code treats single selector.
$('#settingscolumnaggregate') .find('option[value="sum"],option[value="avg"],option[value="max"],option[value="min"]') .hide();
Comments
Post a Comment