JSFiddle - React, Tailwind, and code Playground
CSS
table { margin: 1em; }
JavaScript
$('.mytable tr').each(function() {
var cell = $('td', this);
if (!cell.length)
return alert("Could not find a table cell");
var el = cell.get(0);
if (!el) alert("Could not get first element"); // Won't happen if length was >0
if (!el.childNodes.length)
return alert("Cell is empty!");
var text = el.childNodes[0];
if (cell.contents()[0] != text) alert("different firstChilds???"); // Won't happen
if (text.nodeType != 3)
return alert("the first child node is not a text node!");
var contact = text.nodeValue;
if (text.data != contact) alert("different contents???"); // Won't happen
if (typeof contact != "string") alert("content is no string"); // Won't happen
var newcontact = contact.substring(0,10);
alert(JSON.stringify(contact)+' was changed to '+JSON.stringify(newcontact));
text.data = newcontact;
});