我想选择一个选项“是否进行了修改?”必需,但仅在选择了select选项的情况下。 如果未选择该值,则不需要该值。
非常感谢您的建议和帮助
$(document).ready(function(){
$('#test').on('change', function(){
if (this.value) {
if (this.value == 'radio') {
$('.test1').show();
}
if (this.value == 'tv') {
$('.test1').hide();
}
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js"></script>
<table>
<tr>
<td>Test:</td>
<td><select required id="test" name="test">
<option value="" disabled selected>Choose an option</option>
<option value="tv">tv</option>
<option value="radio">radio</option>
</select> </td>
</tr>
<tr class="test1" style="display:none;">
<td>Has anything been modified?</td>
<td>
<select id="new" name="new">
<option value="U" disabled selected>Select an option</option>
<option value="NO">NO</option>
<option value="YES">YES</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit" class="submit" value="submit"></td>
</tr>
</table>