8 回答

TA貢獻3條經驗 獲得超2個贊
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>test</title>
</head>
<body>
<div id="box">
<input type="button" value="click" id="btn" onclick="action()" />
<p id="msg"></p>
</div>
<script type="text/javascript">
function action(){
var wenti=confirm("你知道嗎?")
if(wenti==true)
{
document.getElementById("msg").innerHTML="你知道什么";
}
else
{
document.getElementById("msg").innerHTML="你怎么什么都不知道";
}
}
</script>
</body>
</html>
不知道是不是想要這么個效果?另外,題主的action方法單詞拼錯…

TA貢獻102條經驗 獲得超139個贊
<input name="button" type="button" value="你知道嗎" onclick="acction()"/ style="position:absolute;left:50%;top:50%;height:50%;width:100px;height:30px;margin:-15px 0 0 -50px">
添加回答
舉報