$("#tipo_input").on("change", function() {
var tipo = $(this).val();
$("span[class^='tipo-']:not(.tipo-"+tipo+")").hide();
$("span[class='tipo-"+tipo+"']").show();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label>Tipo de campo</label>
<select id="tipo_input">
<option value=""> Selecione...</option>
<option value="texto"> Campo de texto</option>
<option value="radio"> Múltipla escolha</option>
<option value="check"> Caixas de seleção</option>
</select>
<br>
<br>
<span class='tipo-texto'>
<label>Campo texto</label>
<input type="text">
<br>
<br>
</span>
<span class='tipo-radio'>
<label>
<input type="radio"> Opção radio 1
<input type="radio"> Opção radio 2
</label>
<br>
<br>
</span>
<span class='tipo-check'>
<label>
<input type="checkbox"> Opção check
</label>
</span>
I don’t know how your HTML is, but you can do something like this:
Note that there are span elements with "type-{type_do_input}" classes involving each type of input, along with their Labels. I use these classes to do the following using Jquery:
What the code does is select span type elements that do not have the "type-{selected type}" class (using the :not selector, see more about it here) and hides them, as well as displaying the span element with the selected class, if this has been hidden previously.
Example link working on Jsfiddle: https://jsfiddle.net/m7dn9Lo4/
Enter the source code of what you have already done and remove the image.
– Don't Panic
Hi Thales. You can put your HTML in the question?
– Sergio
Adds your HTML, which is easier to answer.
– Diogo Henrique Fragoso de Oliv