2 回答
TA贡献2016条经验 获得超9个赞
试试这个
$(document).on("change", "select", function(){
if( $(this).val() == 'Other'){
$('#forshow1').append('<input type="text" name="other" class="form-
control" id="myInput1" />');
}else{
$('#myInput1').remove();
}
});
TA贡献1802条经验 获得超6个赞
你可以试试这种方式。
$('#mylist1').change(function(){
if( $(this).val() == 'Other'){
$('#forshow1').append('<input type="text" name="other" class="form-control" id="myInput1" />');
}else{
$('#myInput1').remove();
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="form-group">
<label for="leave_type">Type of Leave:</label>
<select class="form-control mylist1" id="mylist1" name="leave_type">
<option value="Vacation Leave">Vacation Leave</option>
<option value="Maternity Leave" >Maternity Leave</option>
<option value="Sick Leave" >Sick Leave</option>
<option value="Paternity Leave" >Paternity Leave</option>
<option value="Leave Without Pay" >Leave Without Pay</option>
<option value="Authorized Absence" >Authorized Absence</option>
<option value="Unauthorized Absence" >Unauthorized Absence</option>
<option value="Other">Other</option>
</select>
</div>
<div class="form-group">
<div id="forshow1" class="forshow1">
</div>
</div>
- 2 回答
- 0 关注
- 71 浏览
添加回答
举报