<head>
<meta/>
<title>i learning js now</title>
<script type="text/javascript">
function haha()
var mymessage=confirm("Do you like bone?")
if(mymessage= =ture)
{
document.write("i know,you are a puppy");
}
else
{
document.write("be a lonely dog,come on");
}
</script>
</head>
<body>
<form>
<input type="button" value="haha" onclick="haha()">
</form>
</body>
</html>
4 回答
已采纳
刚毅87
TA贡献345条经验 获得超309个赞
<head> <meta/> <title>i learning js now</title> <script type="text/javascript"> //函数少写大括号了 function haha(){ var mymessage = confirm("Do you like bone?") //'=='中间不能加空格 if (mymessage == ture) { document.write("i know,you are a puppy"); } else { document.write("be a lonely dog,come on"); } } </script> </head> <body> <form> <input type="button" value="haha" onclick="haha()"> </form> </body> </html>
你的错误我都写在代码中了.
望采纳!
ybc4652
TA贡献20条经验 获得超50个赞
function haha(){
var mymessage=confirm("Do you like bone?")
if(mymessage==true){
document.write("i know,you are a puppy");
}else{
document.write("be a lonely dog,come on");
}
}
规范写法
添加回答
举报
0/150
提交
取消