[英]How to get ID off Onclick Button?
I want to get a button onclick ID and apply it to another function. 我想要一个按钮onclick ID并将其应用于另一个功能。
<input type="button" onclick="recordToFilename();" id="submitdis" value="Enter Discount Price" />
And Apply it to 并将其应用于
document.getElementById('discounts').innerHTML = "Discount : $" + ( - discountprice).toFixed(2);
Please check Codepen 请检查Codepen
Thanks for help 感谢帮助
document.getElementById("submitdis")
function recordToFilename() {
var input = document.getElementById('submitdis'),
discount12 = input.value;
Try passing argument to your onclick function 尝试将参数传递给onclick函数
<input type="button" onclick="recordToFilename(this);" id="submitdis" value="Enter Discount Price" />
function recordToFilename(ele)
{
console.log(ele.id);
}
Try: 尝试:
function recordToFilename(e){
$(this).attr("Id")
//or:
e.Id
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.