Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Check boxs and table row back ground colors
- From: nick at nickfitz.co.uk (Nick Fitzsimons)
- Subject: [Javascript] Check boxs and table row back ground colors
- Date: Tue Apr 25 11:00:46 2006
Steve Clay wrote: > Tuesday, April 25, 2006, 11:06:32 AM, Mike Dougherty wrote: > >>loTR.className = loTR.className.replace(/\shighlighted/g,""); /* remove the class */ >>Note: that regexp is probably not 100% right (sorry) > > > /\s*\bhighlighted\b/g > > \s* = zero or more whitespace chars > \b = word boundaries ensure not inside another word > > invaluable regular expression workbench: > http://osteele.com/tools/rework/ > > Steve Unfortunately word boundaries can occur within classNames, as they include hyphens, meaning the above would incorrectly find a match on class="highlighted-blob" instead of just class="highlighted". Use: /(^|\\s)highlighted(\\s|$)/g which will match "highlighted" in the cases of: 1. At start of string followed by whitespace; 2. At end of string preceded by whitespace; 3. At start and end of string - that is, there is no whitespace anywhere. Not my own work - see the comments in Robert Nyman's "Ultimate getElementsByClassName", particularly: <http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/#comment-1583> Cheers, Nick. -- Nick Fitzsimons http://www.nickfitz.co.uk/
- Follow-Ups:
- [Javascript] regexp
- From: Steve Clay
- [Javascript] Check boxs and table row back ground colors
- From: Abyss - Information
- [Javascript] regexp
- References:
- [Javascript] Check boxs and table row back ground colors
- From: Abyss - Information
- [Javascript] Check boxs and table row back ground colors
- From: Mike Dougherty
- [Javascript] Check boxs and table row back ground colors
- From: Steve Clay
- [Javascript] Check boxs and table row back ground colors
- Prev by Date: [Javascript] JavaScript reference guides [WAS: Check boxs and table row back ground colors]
- Next by Date: [Javascript] regexp
- Previous by thread: [Javascript] Check boxs and table row back ground colors
- Next by thread: [Javascript] regexp
- Index(es):