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.
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.
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.