<!DOCTYPE html>
<
html
><
head
></
head
><
body
>
<p> a </p> <p> bb </p> <p> ccc </p> <p> dddd </p>
</
body>
</
html
>
<
script
type
="
text/javascript
"> window.addEventListener('load', function() {
function addEvents(list, type, callback) { [].forEach.call(list, function(el) { el.addEventListener(type, callback); }) } addEvents(document.getElementsByTagName('p'), "click", function(ev) { console.log(this.innerHTML); })
}) </
script
>
<
style
type
="
text/css
">
</
style
>
RESULT: (open your console with F12 or CTRL-SHIFT-K)