試過一個(gè)=也行,為什么要兩個(gè)==
<!DOCTYPE?HTML> <html> <head> <meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/> <title>confirm</title> ??<script?type="text/javascript"> ??function?r(){ ????var?mymessage=confirm("是女士嗎"); ????if(mymessage=true) ????{ ?????document.write("你是女士!"); ????} ????else ????{ ????????document.write("你是男士!"); ????} ??}???? ??</script> </head> <body> ????<input?name="button"?type="button"?onClick="r()"?value="點(diǎn)擊我,彈出確認(rèn)對(duì)話框"?/> </body> </html>
2020-10-22
一個(gè)等號(hào)是賦值給變量,兩個(gè)等號(hào)是判斷變量與比較值關(guān)系
2022-01-30
你不用也行
var mymessage=confirm("你是人妖嗎?");
? ? if(mymessage)
? ? {
? ? document.write("你是女士!");
? ? }
? ? else
? ? {
? ? ? ? document.write("你是男士!");
? ? }
PHP就是不用的,默認(rèn)==true
此外一個(gè)=是賦值,==是比較運(yùn)算符,這是是比較它是不是true,而不是告訴系統(tǒng)它不用選擇都是true