I'm attempting to find the index of the first space in a string from an element's html. In a test case where I simply set a test variable and check the indexOf(' '), it shows up.
For example, the following results in test having a length of 11 characters with the first space at the 5th position, as it should.
var test = 'hello there';
var idxTest1 = test.indexOf(' ');
However, if I set my test variable to a .text() value from a jQuery elements .html(), I'm getting a -1 for the index of the space even when test still appears to be equal to 'hello there' with a length of 11 characters.
What's going on here? http://jsfiddle.net/jhuTB/
.split(/\s/).join(' ')will work. Issue is on encoding space character i guess jsfiddle.net/jhuTB/2