Triggering CSS :active selector for non-anchor elements

后端 未结 2 530
情书的邮戳
情书的邮戳 2021-01-04 11:00

How do I trigger the :active state for non-anchor elements via JavaScript (jQuery)?


While reviewing Section 5.11.3 of the W3C CSS2 specification in reference t

2条回答
  •  渐次进展
    2021-01-04 11:41

    You can't trigger a css pseudo selector like :active with javascript. There is no function / handler which could be executed, so even if you trigger a click on an element which has a css :active pseudo selector set (setting the background color to red for instance), nothing is going to happen.

提交回复
热议问题