Toggle(show/hide) The Selected Odd And Even Columns Of A Table
I have tried the following code, but it is not working for even columns as can be seen from the given example. I couldnot identify the problem. Please help me with necessary correc
Solution 1:
Solution 2:
Every time exec
(or test
, which you might want to use instead) finds a match, it advances a lastIndex
property on the regular expression object, and the next match attempt will start at that position on the string. So when you match "foo", the next search will start at index 3 of "faa" (so you'll be matching against an empty string).
That only happens when your regular expression object uses the global flag "g", so the simplest solution here is to simply remove that flag (since you're not looking for multiple matches within the same class name):
// ...
pattern = /(faa|foo|fii)\b/,
// ...
Also, you should fix your CSS rules as Laughing already pointed out. The semicolons should be inside the curly braces:
.foo{visibility:hidden;}
.faa{visibility:hidden;}
.fii{visibility:hidden;}
Post a Comment for "Toggle(show/hide) The Selected Odd And Even Columns Of A Table"