Question: 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?

Answer: 
You could do it with jQuery.

```
$('.myClass').click(function() {
  alert('hohoho');
});

```
Asking about "a class" in the question title, the answer is `getElementsByClassName`:

```
  var hrefs = document.getElementsByClassName("YOUR-CLASS-NAME-HERE");
  for (var i = 0; i < hrefs.length; i++) {
   hrefs.item(i).addEventListener('click', function(e){
    e.preventDefault(); /*use if you want to prevent the original link following action*/
    alert('hohoho');
   });
  }

```