When #sectionChooser comes from Ajax does not work to select #rua, where would the problem be?
Html
<div class="col-sm-6">
<label for="Planos">Planos</label>
<select name="Planos" id="sectionChooser" class="form-control valid" aria-invalid="false">
<option value="">Selecione</option>
<option value="1">Diamante</option><option value="2">Ouro</option><option value="3">Prata</option><option value="4">Light</option><option value="5">Free</option><option value="19">Link</option>
</select>
<div class="panel" id="1" style="display: block;">
<div class="col-sm-12">
<label><b>Diamante</b></label>
</div>
</div>
<div class="col-sm-6">
<label for="Bairro">Bairro</label>
<select class="form-control valid" name="bairro" id="bairro3" required="" aria-invalid="false">
<option value="">Selecione</option>
<option value="1">teste bairro</option><option value="2">teste bairro 2 3</option><option value="3">ação bairros</option><option value="4">Centro</option>
</select>
</div>
<div class="col-sm-6">
<label for="Rua">Rua</label>
<select class="form-control" name="rua" id="rua" required="">
</select>
</div>
I'm trying like this, but not yet.
$(document).ready(function(){
$(document).on('change', '#sectionChooser', function(){
var myID = $(this).val();
$('.panel').each(function(){
myID === $(this).attr('id') ? $(this).show() : $(this).hide();
console.log("ok");
});
})
$(document).on('change', '#bairro', function(){
var bairroID = $(this).val();
if(bairroID){
$.ajax({
type:'POST',
url:'ajax_data2.php',
data:'bairro_id='+bairroID,
success:function(html){
$('#rua').html(html);
console.log("ok");
}
});
}else{
$('#rua').html('<option value="">Select categoria first</option>');
}
});
});