A string is a primitive type in JavaScript – it cannot be mutated in-place by its methods. When you call split(), the string (innerText) is left alone. A new array is returned from the split() function, so to have access to the array you’ll need to assign it to a variable:
var splitInnerText = innerText.split(',');
alert(splitInnerText.length);
alert(splitInnerText[0]);
Also, [0] simply returns the first character in a string (‘foo’[0] === ‘f’). Note that this is not standardized behaviour, and doesn’t work in all browsers.
Ahh…what an idiot. I’ve literally used this a million times before…after a long day i didn’t even think to do that…I was just thinking it’s a string…this is correct…i’m trying to split a string…WHY WON’T IT WORK!!!
Many thanks JimmyP…you’ve solved my problem and put my mind at rest