Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/452.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当字段值小于数字时显示表行_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 当字段值小于数字时显示表行

Javascript 当字段值小于数字时显示表行,javascript,jquery,html,css,Javascript,Jquery,Html,Css,当年龄值小于15时,我想显示下面隐藏的表行 年龄 守护者 在jQuery中 $("#age").on("input",function() { // or "keyup" or "blur" $(this).closest("tr").next().toggle(this.value<15); }); $(“#age”)。在(“输入”上,函数(){//或“键控”或“模糊” $(this).closest(“tr”).next().toggle(this.value 我稍微修改了您的h

当年龄值小于15时,我想显示下面隐藏的表行

年龄
守护者

在jQuery中

$("#age").on("input",function() { // or "keyup" or "blur"
  $(this).closest("tr").next().toggle(this.value<15);
});
$(“#age”)。在(“输入”上,函数(){//或“键控”或“模糊”
$(this).closest(“tr”).next().toggle(this.value

我稍微修改了您的html:

<table>

  <tr>
    <td>Age</td>
    <td>
      <input type="text" name="age" id="age">
    </td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr id='trGuardian' style="display:none">
    <td> Guardian</td>
    <td>
      <input name="guardian" id="guardian">
    </td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>

</table>

年龄
守护者
和JQuery:

$("#age").blur(function() {
  if (parseInt($(this).val()) < 15)
    $('#trGuardian').show();
  else
    $('#trGuardian').hide();
});
$(“#年龄”).blur(函数(){
if(parseInt($(this).val())<15)
$('#trGuardian').show();
其他的
$('#trGuardian').hide();
});

你能分享到目前为止你所取得的成就吗?欢迎访问,并带去看看什么和如何去问。提示:显示代码和努力。猜测模糊在这种情况下更适合。@拉杰什:不,它不会。当输入失去焦点时,Blur将被触发。@ MeldNANANTWAWAR只考虑你的年龄是31岁的情况。现在当你输入3,处理程序将检查是否