很抱歉问了这么一个基本的问题。说,我有两个输入。第一个始终可见,而第二个仅在第一个的值小于 0 时显示。我尝试使用 .change 来实现此活动,但它不起作用。那么有人可以给我一些建议吗?提前致谢。
HTML 代码:
<table>
<tr><th><label for="id_first">First input:</label></th><td><input type="text" name="First input" id="id_first" /></td></tr>
<tr><th><label for="id_second">Second input:</label></th><td><input type="text" name="First input" id="id_second" />
</td>
</tr>
</table>
jQuery代码
<script type="text/javascript" src=" ../stylesheets/jQuery-1.7.2.js"></script>
<script>
$(document).ready(function() {
$('#id_second').closest('tr').hide();
$('#id_first').change(function() {
if ($(this).val() <0){
$('#id_second').show()}
else{
}
});