Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.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
Jquery 如何在更改同一行中的另一个dom元素时将tr中的输入框作为目标?_Jquery - Fatal编程技术网

Jquery 如何在更改同一行中的另一个dom元素时将tr中的输入框作为目标?

Jquery 如何在更改同一行中的另一个dom元素时将tr中的输入框作为目标?,jquery,Jquery,我试图得到一个文本框的文本值,同时通过这个方法更改同一tr中的其他dom元素,但从未奏效。我们如何才能做到这一点 <table> <tr> <td><input class="drcr" type="text" /><td> <td><input class="jvamt" name="parrot" type="text" /><td> </tr>

我试图得到一个文本框的文本值,同时通过这个方法更改同一tr中的其他dom元素,但从未奏效。我们如何才能做到这一点

<table>
  <tr>
    <td><input class="drcr" type="text" /><td>
    <td><input class="jvamt"  name="parrot" type="text" /><td> 
  </tr>     
</table>    

<script>
  $(".drcr").change(function(){
    var thisval = $(this).parents("tr").children(".jvamt").text();
    alert(thisval);
  })
</script>   

您的逻辑中有几个问题导致了问题

您的HTML无效,因为您缺少输入元素周围的td 添加td时,需要使用find,因为输入不是tr的子项。 您需要使用val来获取输入的值 通过这些修复,它可以正常工作:

$.drcr.changefunction{ var thisval=$this.closesttr.find.jvamt.val; console.logthisval; }
您的HTML无效。没有td在你的轨道上。。。表格用于显示非页面布局的数据。根据@LelioFaieta的建议,编辑TML错误。