Clicking on css content property

后端 未结 2 382
别那么骄傲
别那么骄傲 2021-01-22 01:41

The Following code adds an image before header tag. How can add javascript or jquery code for handling some task when the image added before the header was clicked.



        
相关标签:
2条回答
  • 2021-01-22 02:18

    Pseudo elements such as :before and :after in CSS aren't part of the DOM and can't be altered or interacted with javascript. You would need to add the image to a 'real' element and attach the event handlers to that if you want it to be interacted with.

    0 讨论(0)
  • 2021-01-22 02:41

    You cannot attach events on pseudo class elements since they are not part of the DOM, you can only attach events to the original elements or parents.

    You can create an element containing the image and position it in the same place that the pseudo element is positioning it, and attach any event handler to it.

    0 讨论(0)
提交回复
热议问题