1
I was assembling a feature that aimed to find others selects
of equal value, when I came across this situation :
jQuery('select[name="group2"]').val('emissao');
jQuery('select[name^="group"]').on('change', function(){
console.log(this.value);
var o = null;
console.log(o = jQuery('select[name^="group"][value="'+this.value+'"]'));
console.log(o['selector']);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<select name="group1">
<option value=""></option>
<option value="emissao">Data Emissao</option>
<option value="entrada">Data Entrada</option>
</select>
<select name="group2">
<option value=""></option>
<option value="emissao">Data Emissao</option>
<option value="entrada">Data Entrada</option>
</select>
Note that it already has the new value yet the selector cannot find it.
What is the need to find this select
?
Try
'select[name^="group"] option[value='+this.value+']'
remember that you are trying to access a select child object which is the option...– Gabriel Rodrigues