jQuery:在单击表行上,找到包含的输入文本的值? [英] Jquery: on click table row, find value of contained input text?
本文介绍了jQuery:在单击表行上,找到包含的输入文本的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<table class="container">
<tr>
<td><input type="text" class="foo"></td>
</tr>
<tr>
<td><input type="text" class="foo"></td>
</tr>
<tr>
<td><input type="text" class="foo"></td>
</tr>
</table>
<script>
$(".container tr").click(function(){
alert($(this).find("foo").val());
});
</script>
应该做什么:
当我单击表格行时,它将在此元素内找到输入并提醒其值.
谢谢!
解决方案
您错过了类选择器中的.
:
alert($(this).find(".foo").val());
字段:: http://jsfiddle.net/wUgt5/ >
<table class="container">
<tr>
<td><input type="text" class="foo"></td>
</tr>
<tr>
<td><input type="text" class="foo"></td>
</tr>
<tr>
<td><input type="text" class="foo"></td>
</tr>
</table>
<script>
$(".container tr").click(function(){
alert($(this).find("foo").val());
});
</script>
What it's supposed to do:
When I click on a table row it will find the input inside this element and alert it's value.
Thank You!
解决方案
You miss the .
inside your class selector:
alert($(this).find(".foo").val());
FIDDLE: http://jsfiddle.net/wUgt5/
这篇关于jQuery:在单击表行上,找到包含的输入文本的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文