Quantcast
Channel: DaniWeb Solved Topics
Viewing all articles
Browse latest Browse all 581

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

$
0
0

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


Viewing all articles
Browse latest Browse all 581

Latest Images

Trending Articles



Latest Images