javascript - localStorage的命名规则是怎样的?
PHP中文网
PHP中文网 2017-04-10 16:40:11
0
1
440
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讲师

全部回复(1)
PHPzhong
expression.identifier 
expression[expression]

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

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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板