So I got this html select which is empty, I want the html to be included from js file, but it's simply not injecting... check it out
<select id="province" name="province"></select>
$("select").change(function(){
$( "select option:selected").each(function(){
if($(this).val()=="canada") {
$('#province').innerHTML = '<option value="">Please select your province...</option>';
console.log('Canada baby!');
}
});
}).change();
.change()at the end though which should work in jQuery. I think the main issue is that there’s no$("select option:selected"), thus there’s nothing to iterate over. Except if there are otherselectelements… I don’t know about that.selects,$(this).val()=="canada"can never be true as far as I know because there is novaluefrom a selectedoptionbecause there is nooption.