Access the clicked element

前端 未结 2 886
别那么骄傲
别那么骄傲 2020-12-21 20:53

I have an element like this:

hi

function go() { }

how do I get access to the element that g

相关标签:
2条回答
  • 2020-12-21 21:45

    You could pass this as an argument:

    <p id='foo' onclick='go(this);'>hi</p>
    
    function go(clicked) {
    }
    
    0 讨论(0)
  • 2020-12-21 21:52

    Like this:

    <p id='foo' onclick='go(this)'>hi</p>
    
    function go(elem) {
    }
    
    0 讨论(0)
提交回复
热议问题