Can I toggle the 'active' status of an element to invoke css a:active
properties?
Asked
Active
Viewed 3,473 times
1

Josh Crozier
- 233,099
- 56
- 391
- 304

Stephen
- 582
- 1
- 4
- 11
1 Answers
1
If you hold your mouse down on the anchor element (or any element), it will invoke the active property. If you want to do this dynamically (in JavaScript), you can create a class, a.active
, and add/remove "active"
from the className property on the dom element.

Will
- 19,661
- 7
- 47
- 48
-
What I am looking to do is 'read' the fact that the link is active or not. 'Invoke' the a:active style by simulating a click on the link. – Stephen Sep 05 '11 at 00:22
-
Answer is no, found this thread... http://stackoverflow.com/questions/311052/setting-css-pseudo-class-rules-from-javascript – Stephen Sep 05 '11 at 00:36