Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/475.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中警报消息的条件_Javascript_Function_Html Table - Fatal编程技术网

获取提交按钮的值作为JavaScript中警报消息的条件

获取提交按钮的值作为JavaScript中警报消息的条件,javascript,function,html-table,Javascript,Function,Html Table,我想获取从函数调用的submit按钮的值,该函数将发出警报“function winningcombines()”消息 <input id="Button1" style="width: 100px; text-align:center; height: 100px;" type="button" value="" onclick="chose1()"/></td> </tr> </t

我想获取从函数调用的submit按钮的值,该函数将发出警报“function winningcombines()”消息

                    <input id="Button1" style="width: 100px; text-align:center; height:      100px;" type="button" value="" onclick="chose1()"/></td>

 </tr>
        </table>

 </body>
 </html>
这是我的剧本:

 <!DOCTYPE html>
 <html>
 <body>




    <script>
    var nextTurn = 'X'
    function chose1() {          
       if (document.getElementById("Button1").click = true) {
           if (document.getElementById('Button1').value == "") {
               document.getElementById('Button1').value = nextTurn;
               document.getElementById('Button1').style.fontSize = "30px";
               document.getElementById('Button1').style.color = 'Blue';
               if (document.getElementById('Button1').value == "O") {
                   document.getElementById('Button1').style.color = 'Red'
               }
                   changeTurn();
               }
           }

       }
    function winningcombinations() {
           if (document.getElementById('Button1').value == "X" ) {
               alert("Congratulations X you won!!");
           }
       }
 </script>
                    <input id="Button1" style="width: 100px; text-align:center; height:      100px;" type="button" value="" onclick="chose1()"/></td>

 </tr>
        </table>

 </body>
 </html>

var nextTurn='X'
函数chose1(){
if(document.getElementById(“Button1”).click=true){
if(document.getElementById('Button1')。值==“”){
document.getElementById('Button1')。value=nextTurn;
document.getElementById('Button1').style.fontSize=“30px”;
document.getElementById('Button1')。style.color='Blue';
if(document.getElementById('Button1')。值==“O”){
document.getElementById('Button1')。style.color='Red'
}
changeTurn();
}
}
}
函数winningcombinations(){
if(document.getElementById('Button1')。值==“X”){
提醒(“恭喜你赢了!!”;
}
}
这是我正在使用的9个按钮之一:

                    <input id="Button1" style="width: 100px; text-align:center; height:      100px;" type="button" value="" onclick="chose1()"/></td>

 </tr>
        </table>

 </body>
 </html>

您可以试试这个。从onclick自身传递值,使用
此值

                    <input id="Button1" style="width: 100px; text-align:center; height:      100px;" type="button" value="" onclick="chose1()"/></td>

 </tr>
        </table>

 </body>
 </html>
<input id="Button1" style="width: 100px; text-align:center; height:100px;"type="button" value="X" onclick="chose1(this.value)"/></td>

你能做一把小提琴吗??