获取提交按钮的值作为JavaScript中警报消息的条件
我想获取从函数调用的submit按钮的值,该函数将发出警报“function winningcombines()”消息获取提交按钮的值作为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
<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>
你能做一把小提琴吗??