I have some javascript which changes a string of numbers within a table to a nicer looking date format with /'s between the year month and day. So far I've only been successful in Chrome and I've tried to manipulate it using innerHTML, innerText and contentText, all fine on Chrome but no other browsers.
My Javascript looks like this:
window.onload = function ()
{
var formatForDate = function(element) {
var originalText = element.innerHTML;
var year = originalText.substring(0,4);
var month = originalText.substring(4,6);
var day = originalText.substring(6,9);
element.innerHTML = [day, month, year].join('/');
formatForDate(document.querySelector('#\\31 3113'));
}
And here is the html I am trying to manipulate:
<table>
<tbody>
<tr><td>Something</td><td>Something</td></tr>
<tr><td>Something</td><td><span id='13113'>20150924</span></td>
</tbody>
</table>
Please help! I can only use javascript to solve this, unfortunately no jQuery.