Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在javascript中更改href函数的参数值_Javascript_Html - Fatal编程技术网

如何在javascript中更改href函数的参数值

如何在javascript中更改href函数的参数值,javascript,html,Javascript,Html,有一个具有2个参数的功能工具。我必须改变参数a(1到2)和b(2到3)的值。我怎样才能改变这个?请给出你有价值的答案 <html> <head> <script> function tool(a,b) { } </script> </head> <body> <a href="javascript:tool(1,2)" name ="link" title="before click">click her

有一个具有2个参数的功能工具。我必须改变参数a(1到2)和b(2到3)的值。我怎样才能改变这个?请给出你有价值的答案

<html>
<head>
<script>

function tool(a,b) {
}   
</script> </head>
<body>
<a href="javascript:tool(1,2)" name ="link" title="before click">click here</a>
</body>
</html>

功能工具(a、b){
}   

您可以更新锚节点的
href
属性

功能工具(a、b){
控制台日志(a,b);
}
document.getElementById('link')。href='javascript:tool(2,3);'

使用你想做的事情。但你的问题不清楚。据我所知,我正在给你答案

答案1

功能工具(a、b){
控制台日志(a,b);
document.getElementById('link')。href='javascript:tool(2,3);';
}

您可以添加事件侦听器:

功能工具(a、b){
控制台日志(a,b);
}
document.getElementById(“链接”).addEventListener('click',
职能(e){
e、 预防默认值();
工具(2,3);
});

我不知道问题出在哪里?只需更改方法调用中的值