javascript - Remove option from select where text started with 'aa' -
i have select options:
<select id="sel"> <option value="1">aadkdo</option> <option value="2">sdsdf</option> <option value="3">aasdfsddkdo</option> <option value="4">aadkfsdfdo</option> <option value="5">sdfs</option> <option value="6">aafsdfdkdo</option> <option value="7">sdfsdf</option> </select>
how can remove select option text started aa. example thera 1, 3, 4 , 6.
$('#sel option').each(function(){ if(???){ $(this).remove(); } })
fiddle: http://jsfiddle.net/azxew/
try this;
$(document).ready(function() { $('#sel option').each(function(){ if ($(this).html().substring(0, 2) == 'aa'){ $(this).remove(); } }) });
Comments
Post a Comment