[英]Jquery Passing this as function parameter
<input type="button" id="1" class="add" value="+" title="Add" onclick="set(this);"/>
function set(obj){
alert(obj.id);
}
The above code is not working. 上面的代码不起作用。
I need to pass the id attribute of the button in the onclick function. 我需要在onclick函数中传递按钮的id属性。 Is there any way I could achieve this. 有什么办法可以实现这一目标。
Your html should be 您的html应该是
<input type="button" id="1" class="add" value="+" title="Add" onclick="set(this.id);"/>
and write java script function as 并编写Java脚本函数为
function set(id)
{
alert(id);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.