爲什麼surveyName的值不會改變?Javascript變量
<script type = 'text/javascript'>
surveyName = "catNull";
function test(){
window['surveyName'] = "catTest";
}
</script>
</head>
<body>
<input onclick = 'test()' id = 'cat' class = 'test' type = 'button' value = 'category' />
<script>
document.write('<input id = "survey" class = "test" type = "button" value = "'+surveyName+'" />');
</script>
只有單擊按鈕後它纔會更改。 – Mrchief
如果一個網頁中的變量發生變化,但是沒人看到它,它真的發生了變化嗎? – SLaks
SLaks,你的意思是Shroedinger的貓的JavaScript版本? :) –