Let’s say I want that every time the user click any link an alert pops up that says “hohoho”.
Do I need to add onclick="alert('hohoho')" to every link or can I set this with CSS so that it works with every link?
Let’s say I want that every time the user click any link an alert
Share
You can’t do it with just CSS, but you can do it with Javascript, and (optionally) jQuery.
If you want to do it without jQuery:
And to do it without jQuery, and only on a specific class (ex:
hohoho):If you are okay with using jQuery, then you can do this for all anchors:
And this jQuery snippet to only apply it to anchors with a specific class: