小编sri*_*tno的帖子

在同一功能上使用多个按钮,重定向到不同的功能

所以..我有几天这个问题不知道怎么做,我需要帮助.

我有多个按钮,然后单击所有按钮将我重定向到相同的功能,并从该功能转到另一个为该按钮指定的功能.知道我怎么能知道哪些功能知道单击了哪个按钮?例如:

 <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)

html javascript function button

7
推荐指数
2
解决办法
4万
查看次数

是否可以将输入类型:“颜色”设为只读?

<input type="color" readonly name="favcolor">
Run Code Online (Sandbox Code Playgroud)

这不起作用。还有其他建议吗?

html input

3
推荐指数
1
解决办法
2521
查看次数

标签 统计

html ×2

button ×1

function ×1

input ×1

javascript ×1