[英]jQuery DOM Traversal with closest()
I have a table with the row below: 我有一个表格,下面有一行:
When the span field in the second td is clicked I want to change the text in the td.enPublish for the row. 单击第二个td中的span字段时,我想更改该行的td.enPublish中的文本。
What I have now is 我现在拥有的是什么
$('span#publish_field').click (function() {
title = this.title; // this is a raw DOM span node, so we can go directly after the title attribute.
$(this).closest("tr").$('td.enPublished').text('steve');
$.post("set_publish.php", { "product_id" : title }, function(echoed_data) {
alert (echoed_data);
});
The third line is supposed to get at that field, but it doesn't. 第三行应该是在那个领域,但事实并非如此。 Does anyone see the problem?
有谁看到这个问题?
The title attribute holds a product_id value for that row and is used in the ajax call to set a field in the database. title属性包含该行的product_id值,并在ajax调用中用于在数据库中设置字段。 I thought I could also update the field here in the HTML so the user wouldn't have to refresh the page to see it.
我想我也可以在HTML中更新这里的字段,这样用户就不必刷新页面就可以看到它了。
Thanks for any ideas. 谢谢你的任何想法。
更改$
以find
$(this).closest("tr").find('td.enPublished').text('steve');
use find()
使用
find()
try this 尝试这个
$(this).closest("tr").find('td.enPublished').text('steve');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.