大家好我得到我的代碼都很漂亮,但問題是,它有點bug。當您選擇實際隱藏某個部分的字段,然後選擇隱藏該部分的字段時,「隱藏」部分仍然存在一段時間! 下面你將看到我的代碼上codepen:http://codepen.io/Nestalna/details/qpjsy基於dropdown顯示/隱藏部分-js
的Javascript:
function show(aval) {
if (aval == "1") {
optionyes.style.visibility='visible';
optionyes.style.display='block';
Form.fileURL.focus();
}
if (aval == "0") {
optionyes.style.visibility='hidden';
optionyes.style.display='none';
}
}
HTML:
<div class="row">
<label id="title" for="degree">Which degree are you interested in? </label><br />
<select id="degree" name="degree" onchange="java_script_:show(this.options[this.selectedIndex].value)" >
<option selected="selected" value="Please select one"> Please select one </option>
<option value="0" > Concurrent Enrolment </option>
<option value="1" > 2015 Applied Bioethics Summer Study </option>
<option value="2"> Non Degree (9 hours or less) </option>
</select>
</div>
<div id="optionyes" style="visibility:hidden" >You have selected <strong>red option</strong> so i am here </div>
仔細檢查你的鏈接到codepen.io - 它爲我返回404。 – Moob 2014-09-26 15:50:04
對不起,嘗試:http://codepen.io/Nestalna/details/qpjsy – Nestalna 2014-09-26 15:51:23