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

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -