javascript - localStorage的命名规则是怎样的?
PHP中文网
PHP中文网 2017-04-10 16:40:11
0
1
435
for(var i=1;i<=setid;i++){
        localStorage.setItem("reason"+i,$("#reason"+i).val());
        //document.getElementById("yourID").value;
        alert(localStorage.getItem("reason"+i));
        
        }
        alert(localStorage[reason1]);
    });

localStorage[reason1]输出undefined

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
PHPzhong
expression.identifier 
expression[expression]

localStorage["reason1"] === localStorage.reason1

改成
alert(localStorage.reason1)或者alert(localStorage["reason1"])

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template