I have a table wher开发者_Go百科e every row has a unique id. The last table cell has class="status" where I want to show the user the result of their action.
In my $.ajax call, I have:
,success: function(result){
$('tr#'+result).td('.status').text('Updated');
};
result is the id of the row that was updated.
It's just throwing an error message that says $( and that's all.
There are no method named .td()
. This is probably what you are looking for:
$('tr#' + result + ' td.status').text('Updated');
Also make sure that result
has valid value.
console.log(result);
You didn't post whole code, but it looks like parse error – the code should probably end with });
, not };
.
Ancestory/descendant relationships can be put in a single $ call like this:
$('tr#' + result + ' td.status').text('Updated');
Just remember to put a space between the ancestor and child. Example output:
$('tr#row10 td.status').text('Updated');
Additionally, an ID should only be sued once, so you could probably omit the initial tr, like:
$('#' + result + ' td.status').text('Updated');
See http://api.jquery.com/descendant-selector/
精彩评论