I hope there is a shorter way to check if an option inside sela
exists.
Any suggestion?
var str = 'white moon';
var x = 0;
$('#sela > option').each(function(){
if($(this).text() == str){x = 1;}
});
if(x == 1){console.log(x);}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select id='sela'>
<option>blue sky</option>
<option>gold sun</option>
<option>white moon</option>
</select>