I have an issue where I need to format html that’s stored in a client cache in the following format:
html[0] = '<tr>'
html[1] = '<td>text</td>'
html[2] = '<td>text</td>'
On normal occasions I work directly with the dom and don’t need to go near this cache but sometimes I need to update it like so…
html[1] = '<td><a href="">text</a></td>'
Because of the ‘unusual’ storage of the opening ‘tr’ am I able somehow to construct a new ‘tr’, manipulate it, then render only the opening tag?
$(html[0] + '</tr>');
I’m aware this could be done with regexp but curious to know if there’s a jquery technique I can use.
HTML is not XML. In HTML this is perfectly legal:
That means that you don’t have to close the opening
<tr>bracket with</tr>.You can use the W3C Markup Validation Service to check your HTML for validness.
You can wrap the text with an anchor like this: