javascript - Toggle a hidden div when a particular dropdown option is either selected or de-selected -
i able find example on stackoverflow wanted. however, when implement in code , select option display hidden div, hidden div not appear , not sure why.
html:
<td class="mm1" width="40%"> <br /> <ul> <li> <label for="name">please select company below:</label> <select class="selectmenu" id="select"> <option selected disabled class="hideoption">please select 1 company</option> <option value="0">rmg</option> <option value="1">lmg</option> <option value="2">csc</option> <option value="3">adoc</option> </select> <div id="hidden_div" style="color:#b9b9b9; display:none"> if adoc-does<br />position support ucmg?<br /> <input type="checkbox" /> yes <input type="checkbox" /> no </div> </li> </ul></td>
css:
/*simple dropdown box*/ .selectmenu{ font-family: arial, sans-serif, tahoma; -webkit-appearance: none; /*removes default chrome , safari style*/ -moz-appearance: none; /* removes default firefox style*/ background: white; width: 80px; /*width of select dropdown give space arrow image*/ text-indent: 0.01px; /* removes default arrow firefox*/ text-overflow: ""; /*removes default arrow firefox*/ /*my custom style fonts*/ color: black; border-radius: 2px; padding: 5px; border:0 !important; box-shadow: inset 0 0 1px rgba(000,000,000, 0.5); font-size: 1.2em; }
javascript:
$(function() { $('#select').change(function(){ if ($(this).val() == "3") { $('#hidden_div').show(); } else { $('#hidden_div').hide(); } }); });
i tried code. working. maybe try alternatives. use .css() function of jquery change display none block , vice versa.
$(function() { $('#select').change(function(){ if ($(this).val() == "3") { $('#hidden_div').css('display','block'); } else { $('#hidden_div').css('display','none'); } }); });
here's screenshot prove works:
hope helps. goodluck!
Comments
Post a Comment