Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Javascript
Element.getElementsByClassName() IE and Opera Bugs
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Lachlan Hunt, post: 4898561"] Thanks, I should have got more information about what \b matches. The JavaScript 1.5 Reference only states [1]: | Matches a word boundary, such as a space. (Not to be confused with | [\b].) So I thought it only matched white space or the start/end of the line, I didn't realise it also matched a hyphen and probably other characters too. I replaced the regex with new RegExp("(^|\\s)" + className + "(\\s|$)", flags).test(classNames); It now passes your test cases and all of mine. [1] [URL]http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:RegExp[/URL] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Javascript
Element.getElementsByClassName() IE and Opera Bugs
Top