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 can't do it with just CSS, but you can do it with Javascript, and (optionally) [jQuery](http://jquery.com).

If you want to do it without jQuery:

```
<script>
    window.onload = function() {
        var anchors = document.getElementsByTagName('a');
        for(var i = 0; i < anchors.length; i++) {
            var anchor = anchors[i];
            anchor.onclick = function() {
                alert('ho ho ho');
            }
        }
    }
</script>

```

And to do it without jQuery, and only on a specific class (ex: `hohoho`):

```
<script>
    window.onload = function() {
        var anchors = document.getElementsByTagName('a');
        for(var i = 0; i < anchors.length; i++) {
            var anchor = anchors[i];
            if(/\bhohoho\b/).match(anchor.className)) {
                anchor.onclick = function() {
                    alert('ho ho ho');
                }
            }
        }
    }
</script>

```

If you are okay with using [jQuery](http://jquery.com), then you can do this for all anchors:

```
<script>
    $(document).ready(function() {
        $('a').click(function() {
            alert('ho ho ho');
        });
    });
</script>

```

And this jQuery snippet to only apply it to anchors with a specific class:

```
<script>
    $(document).ready(function() {
        $('a.hohoho').click(function() {
            alert('ho ho ho');
        });
    });
</script>

```
Following JCOC611 suggestion:

```
window.onload = function() {    
    let elements = document.getElementsByClassName("someClassName");

    for(let i = 0; i < elements.length; i++) {
        elements[i].onclick = function () {
            alert("Clicked in an element of the class.");
        }
    }
};

```