I have found many answers to the question:
How do I show/hide DIV on selection of \"Other\" dropdown value.
However I cannot fin
Javascript
var elem = document.getElementById("security_question_1");
elem.onchange = function(){
var hiddenDiv = document.getElementById("showMe");
hiddenDiv.style.display = (this.value == "") ? "none":"block";
};
HTML
<select class="default" id="security_question_1" name="security_question_1">
<option value="" selected>Select question...</option>
<option value="1">Question One</option>
<option value="2">Question Two</option>
<option value="3">Question Three</option>
<option value="4">Question Four</option>
<option value="5">Question Five</option>
<option value="6">Question Six</option>
</select>
<div id="showMe">Value Selected</div>
CSS
#showMe{
display:none;
}
FIDDLE http://jsfiddle.net/Sj5FN/1/
Try this -
$( "#security_question_1" ).change(function () {
if($( "option:selected", this ).text()=="text you want to match"){
$("#div-id").hide();
}else{
$("#div-id").show();
}
});
Try this:
HTML:
<div>
<select>
<option value="choose">Choose Color</option>
<option value="red">Red</option>
<option value="green">Green</option>
<option value="blue">Blue</option>
</select>
</div>
<div class="choose box">You have to select <strong>any one option</strong> so i am here</div>
<div class="red box">You have selected <strong>red option</strong> so i am here</div>
<div class="green box">You have selected <strong>green option</strong> so i am here</div>
<div class="blue box">You have selected <strong>blue option</strong> so i am here</div>
Javascript:
$(document).ready(function(){
$("select").change(function(){
$( "select option:selected").each(function(){
if($(this).attr("value")=="red"){
$(".box").hide();
$(".red").show();
}
if($(this).attr("value")=="green"){
$(".box").hide();
$(".green").show();
}
if($(this).attr("value")=="blue"){
$(".box").hide();
$(".blue").show();
}
if($(this).attr("value")=="choose"){
$(".box").hide();
$(".choose").show();
}
});
}).change();
});
as per your requirement