Today I use this function to disappear the div, works perfectly, But I need the field already selected / option value="tickets" selected / Tickets / option / but the function only executes when it changes because this is set onchange, is there an event load that when opening the screen identify what is selected in the option and execute the function? onload, onpageshow, etc. not working
In short, when the screen opens it identifies that the "Tickets" field is selected and the others are hidden.
VALEU !!
function ocultar_div(){
$('.div-sel').hide();
$('#TipodeDocumento_6').on('change', function() {
var selecionado = $(this).val();
$('.div-sel').each(function() {
if ($(this).attr('id') == selecionado) {
$(this).toggle();
} else {
$(this).hide();
}
});
});
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><divclass="col-md-3" >
<div class="form-group">
<label for="TipodeDocumento_6" >Tipo de Documento</label>
<select class="form-control" name="TipodeDocumento_6" id="TipodeDocumento_6">
<option value="">Selecione</option>
<option value="Contratos_Aditivos">Contratos e Aditivos</option>
<option value="Notas_Fiscais">Notas Fiscais</option>
<option value="boletos" selected>Boletos</option>
</select>
</div>
</div>
<div class="div-sel panel panel-default" id="boletos">
<div class="panel-heading ">
<h3 class="panel-title"> <b>Boletos</b> </h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label for="ServioProduto_4">Serviço/Produto</label>
<input type="text" class="form-control" name="ServioProduto_4" id="ServioProduto_4">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="RazaoSocial_Boletos">Razão Social</label>
<input type="text" class="form-control" name="RazaoSocial_Boletos" id="RazaoSocial_Boletos">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="CNPJFornecedor_Boletos">CNPJ do Fornecedor</label>
<input type="text" class="form-control" name="CNPJdoFornecedor_10" id="CNPJdoFornecedor_10">
</div>
</div>
</div>
</div>
</div>