如何通过 JavaScript (jQuery) 触发非 anchor 元素的 :active 状态?
在审查时 Section 5.11.3 of the W3C CSS2 specification在引用 :hover pseudo selector to see about triggering a activation 时,我遇到了以下内容,这让我相信它应该是可能的:
"The :active pseudo-class applies while an element is being activated by the user. For example, between the times the user presses the mouse button and releases it."
"CSS does not define which elements may be in the above states, or how the states are entered and left. Scripting may change whether elements react to user events or not, and different devices and UAs may have different ways of pointing to, or activating elements."
感谢您的协助!
最佳答案
你不能用 javascript 触发像 :active
这样的 css 伪选择器。
没有可以执行的函数/处理程序,因此即使您在具有 css :active
伪选择器的元素上触发
单击
设置(例如将背景颜色设置为红色),什么都不会发生。
关于javascript - 触发 CSS :active selector for non-anchor elements,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2990687/