-5
什麼錯我的代碼?結果表明DemoUser作爲undefined.heres我做了什麼文本轉向未定義
<!DOCTYPE html>
<html>
<head>
</head>
<body>
Name : <span id="pname">DemoUser</span><button type="button" onclick="setname()">Edit</button>
<script type="text/javascript">
var nme;
document.getElementById("pname").innerHTML=nme;
function setname(){
nme = prompt("Enter your name","");
if (nme != "" && nme != ""){
setCookie("player",nme,300);
}
}
</script>
</body>
</html>
'nme'在您將其賦值給'innerHTML'時沒有值。你還期望什麼? – 2014-12-05 14:40:24
'if(nme!=「」&& nme!=「」)'?很高興你檢查兩次? – j08691 2014-12-05 14:42:56
哈哈im sorry ..im真的不知道..真的很哈哈:D – aRvinR 2014-12-05 14:46:49