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

I solved I'm cool ahhaahah :)

    let x= $(event.target).text();
    console.log(x);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.