如何在javascript中使用函数作为另一个函数的参数(how to use a function as a argument of another function in javascript)
<input type="button" id="one" value="1" OnClick='addValue("function(){document.getElementById("one")}")'>
我想将此输入的id作为addValue函数的参数传递。 这里的错误在哪里?
<input type="button" id="one" value="1" OnClick='addValue("function(){document.getElementById("one")}")'>I want to pass the id of this input as argument of addValue function. Where is the mistake here ?
最满意答案
你过度复杂,使用this
<input type="button" id="one" value="1" OnClick='addValue(this.id)'>You're overcomplicating things, use this
<input type="button" id="one" value="1" OnClick='addValue(this.id)'>更多推荐
发布评论