There is a table with a column which I want to separate in two. The cell's content of this column is e. g.
| Miami: banana |
| Ft. Myers: pineapple |
Now I want to split this into two columns (and cells) to appear like this:
| Miami | banana | // <td> Miami </td><td> banana </td>
| Ft. Myers | pineapple | // <td> Ft. Myers </td><td> pineapple </td>
I made a JavaScript to achieve this:
function foo(str) {
result = str.replace(": ", "</td><td>");
}
$("td.valueCol").each(function(){
$("td.valueCol").html(foo($(this).text()));
}
The result however is:
| bananas | // <td>bananas</td>
| pineapple | // <td>pineapple</td>
When I test it with a not parsed tag like result = str.replace(": ", "</xt><xt>") it shows, that the tags are swapped and quotation marks are added to the part before the tag:
| Miamibarbananas | // <td>"Miamibar"<xt>bananas</xt></td>
| Ft. Myersbarpineapple |
Obviously replace or html() applies some sort of sanitizing. What is this, and what do I have to do to make it work properly?
//in your expected result?//is just to separate the resulting HTML markup from the appearance. :-)