It is odd.
I have a list item containing the text 'May 13, 2011'. I have many such dates, and I want to use jQuery to search for them using free text input (they do not always refer to dates), but I can not find anything if I put a space in the search field.
but
li.text() // 13 May 2011 li.text().indexOf('13') // 0 li.text().indexOf('13 ') // -1 li.text().indexOf(' ') // -1 '13 May 2011'.indexOf('13') // 0 '13 May 2011'.indexOf('13 ') // 0 li.text() == '13 May 2011' // false
I inserted my return text into a converter with the text in hexadecimal, and the whitespace is “20” (32 in decimal, this is a space in ASCII), so this is not a funny space character.
Has anyone encountered this problem before? Does anyone have any other ideas?
Connell
source share