我试图获取具有articleNnumber ID的tr来隐藏自身,直到从具有类型ID的select中选择Update或Clarification为止。我尝试了在这里找到的几个不同的jquery示例,但是我一生无法正常工作,因此决定寻求帮助
<form id="test">
<table id="article">
<tr>
<th>Name:</th>
<td><input type="text" name="name" placeholder="Frist and Lastname" /></td>
</tr>
<tr>
<th>Account:</th>
<td><select name="client">
<option value="">Select an Account:</option>
<option value="test1">test 1</option>
<option value-"test2">test</option>
</select>
</td>
<tr>
<th>Type:</th>
<td><select id="type">
<option value="">Select One...</option>
<option value="new">New</option>
<option value="update">Update</option>
<option value="clarify">Clarification</option>
</select>
</td>
<tr id="articleNumber">>
<th>Article Number:</th>
<td><input type="text" name="article" placeholder="Enter Article" /></td>
</tr>
<tr>
</tr>
</table>
</form>
我假设如果用户切换到“更新”或“澄清”位置,您也希望隐藏此元素
从articleNumber
隐藏开始
<tr id="articleNumber" hidden>
添加以下JQuery
$(function(){
$('#type').change(function() {
if($(this).val() === 'update' || $(this).val() === 'clarification') {
$('#articleNumber').show();
} else {
$('#articleNumber').hide();
}
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句