javascript - Only detect click event on pseudo-element -
my code is:
p { position: relative; background-color: blue; } p:before { content: ''; position: absolute; left:100%; width: 10px; height: 100%; background-color: red; }
please see fiddle: http://jsfiddle.net/zww3z/5/
i trigger click event on pseudo-element (the red bit). is, don't want click event triggered on blue bit.
this not possible; pseudo-elements not part of dom @ can't bind events directly them, can bind parent elements.
if must have click handler on red region only, have make child element, span
, place right after opening <p>
tag, apply styles p span
instead of p:before
, , bind it.
Comments
Post a Comment