Dev P Dev P - 2 months ago 16
jQuery Question

Changing/replacing table column values using jQuery

I have the following table structure:

<table class=ms-listviewtable>
<tr class="ms-itmhover">
<td class="ms-vb2">Value1</td>
<td class="ms-vb2">Value2</td>
<td class="ms-vb2">Value3</td>
<td class="ms-vb2 ms-lastCell">Value4</td>

I would like to be able to change the value of the last column which is currently "Value4" to "changedValue" for example using jQuery;

I have written the following but it does not seems to be working at all, not really sure where I am going wrong:

$(document).ready(function() {
$('.ms-vb2 .ms-lastCell').each(function() {
var lastColumn = $(this).html();
var replaceValue = lastColumn.Append("Changed Content");


Any suggestions will be greatly appreciated.


I understand that you want to append text to the last td. Here is the code for that

jQuery('.ms-lastCell').each(function() {

 var lastColumn = $(this).html();
 var replaceValue = lastColumn + "Changed Content";

jQuery(this).html(replaceValue );