所以..我有几天这个问题不知道怎么做,我需要帮助.
我有多个按钮,然后单击所有按钮将我重定向到相同的功能,并从该功能转到另一个为该按钮指定的功能.知道我怎么能知道哪些功能知道单击了哪个按钮?例如:
<html>
<button type="button" onclick="myFunction()" id="1">Button1</button>
<button type="button" onclick="myFunction()" id="2">Button1</button>
<button type="button" onclick="myFunction()" id="3">Button1</button>
<script>
function myFunction()
{
var x=0;
if (button 1){
x=1;
myFunction1(x);}
if (button 2){
x=2;
myFunction2(x);}
if (button 3){
x=3;
myFunction3(x);}
...
myFunction3(x){
alert(x);
}
}
</script>
</html>
Run Code Online (Sandbox Code Playgroud) <input type="color" readonly name="favcolor">
Run Code Online (Sandbox Code Playgroud)
这不起作用。还有其他建议吗?