3
Hi I have my page code
<select class="form-control" id="selected">
<option selected="selected" value="0">Selecione</option>
<option value="a">MONTAGEM LATERAL</option>
<option value="b">MONTAGEM TETO</option>
<option value="c">MONTAGEM SEMI-EMBUTIDA</option>
<option value="d">MONTAGEM SOBRE A BASE</option>
</select>
<div id="colors">
<div id="a">
<p>a</p>
</div>
<div id="b">
<p>b</p>
</div>
<div id="c">
<p>c</p>
</div>
<div id="d">
<p>d</p>
</div>
in a separate javascript file I have the following code
$(function(){
$("#selected").change(function(){
$('#colors div').hide();
$('#'+$(this).val()).show();
});
});
What is happening is that, is appearing all div and only when I choose one that hides the other div and appears the correct one, but the correct one would be when loading the page hide all div and only appear when selected. Apparently there’s something wrong with my javascript code
"Apparently there is something wrong with my java code"... Javascript is very different from Java. (Javascript is for wine as well as Java is for sanitary water Hahahahahaha)
– MarioAleo
Your code is right and maybe the problem jquery, follows below the example of pure javascript. Jquery: http://codepen.io/KingRider/pen/KNVxwN and Javascript Pure: http://codepen.io/KingRider/pen/mOVGMd
– KingRider