我正在尝试创建一个表单,当选择选择元素“parcel”时,它将显示一个 div,但当未选择它时,我想隐藏该 div。这是我目前的标记:
到目前为止,这是我的 HTML..
<div class="row">
Type
<select name="type" id="type" style="margin-left:57px; width:153px;">
<option ame="l_letter" value="l_letter">Large Letter</option>
<option name="letter" value="letter">Letter</option>
<option name="parcel" value="parcel">Parcel</option>
</select>
</div>
<div class="row" id="row_dim">
Dimensions
<input type="text" name="length" style="margin-left:12px;" class="dimension" placeholder="Length">
<input type="text" name="width" class="dimension" placeholder="Width">
<input type="text" name="height" class="dimension" placeholder="Height">
</div>
这是我到目前为止的 jQuery..
$(function() {
$('#type').change(function(){
$('#row_dim').hide();
$("select[@name='parcel']:checked").val() == 'parcel').show();
});
});
使用以下 JQuery。Demo http://jsfiddle.net/Y3pW9/
$(function() {
$('#row_dim').hide();
$('#type').change(function(){
if($('#type').val() == 'parcel') {
$('#row_dim').show();
} else {
$('#row_dim').hide();
}
});
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)