[英]How would I pass an onclick value to another button?
What I am trying to accomplish is I have a data table, and there's a button for each dr. 我要完成的工作是有一个数据表,每个博士都有一个按钮。 I would like to set-it-up to where when the button in each dr is clicked, it passes it's onclick function, and variable, to another button.
我想设置为单击每个dr中的按钮时将其onclick函数和变量传递给另一个按钮的位置。
The button I would like to take the function out of looks like this: 我想要删除功能的按钮如下所示:
<button onclick="buyPhone('17729198426','(772) 919-8426');" type="button">Acquire</button>
And the target button looks like this: 目标按钮如下所示:
<button id="saveNumber" type="button" class ="viewcust_tbl_new_button" onclick="">Save</button>
您可以将事件函数从一个元素复制到另一个元素,如下所示:
document.getElementById('button1').click = document.getElementById('button2').click;
您可以在功能buyPhone中添加以下内容:
$('#saveNumber').attr('onclick', yourFuncFromTheFirstButton);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.