获取jQuery中所选tr的td值 [英] Getting a value of td of a selected tr in jquery
本文介绍了获取jQuery中所选tr的td值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是我的表
< table>
< tr class = chargeTR>
< td id = chargeTD>
charge1
< / td>
< / tr class = chargeTR>
< td id = chargeTD>
charge2
< / td>
< / tr>
< table>
下面是我的jQuery调用
<$ p $ ($。$ charge $)。$(。chargeTR)。each(function(){// this line works fine
$ .get(process.php,{
value:$ (this).find(#chargeTD)。val(),//我必须在这里做一些错误...
},function(theXML){
alert(theXML);
});
});
我无法获得值charge1和charge2。
有人可以请我纠正这个问题吗?
解决方案使用
.text )
或 .html()
而不是 .val()
,因为 .val
旨在从表单获得 value =
属性。 Below is my table
<table>
<tr class=chargeTR>
<td id=chargeTD>
charge1
</td>
</tr class=chargeTR>
<td id=chargeTD>
charge2
</td>
</tr>
<table>
Below is my jQuery call
$(".chargeTR").each(function() { // this line works fine
$.get("process.php", {
value: $(this).find("#chargeTD").val(), // I must be doing something wrong here...
}, function(theXML){
alert(theXML);
});
});
I cannot get the value "charge1" and "charge2".
Can somebody please correct me in this?
解决方案
use .text()
or .html()
instead of .val()
, since .val
is intended to get value=""
attributes from forms.
这篇关于获取jQuery中所选tr的td值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文