How to get text from different elements, with a single function.

Hello.
It is something very simple for someone who knows javascript.
How to capture the text content of the pressed element? Important is that the page is built with PHP.

<li><a onclick='cat();' href='#'>Text 1</a></li>
<li><a onclick='cat();' href='#'>Text 2</a></li>
<!-- Above PHP, important: text content element is dinamic-->
<script>
  function cat() {
  var x = ?? /*Text 1 or text 2 or any PHP text*/
    console.log(x);

}
</script>

Thank you very much