Is it possible to get the value of a element using onclick?

前端 未结 6 1599
[愿得一人]
[愿得一人] 2020-12-22 07:51

I currently have a table that has a list of email template names being echoed using php. Below is part of the php code. I\'m trying to grab the table value and pass it to

6条回答
  •  离开以前
    2020-12-22 08:32

    You id attribute would be the same for every td inside the loop. So JS would not know which element you want.

    You could try passing this into the onclick method

    HTML

    
    

    JS

    function moveValue( elem )
    {
        alert(elem.innerHtml);
    }
    

    I would take a look at jQuery if I were you. It makes all this stuff much easier to achieve.

提交回复
热议问题