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讲师
expression.identifier expression[expression] localStorage["reason1"] === localStorage.reason1
改成alert(localStorage.reason1)或者alert(localStorage["reason1"])
改成
alert(localStorage.reason1)或者alert(localStorage["reason1"])