2

对于一些大学课程,我正在尝试使用 jQuery 和 sessionStorage 以便我可以跨页面存储数据,但是在执行以下行时它会崩溃:

eDiffpl = eventDate.getTime() - pageLoadDate.getTime() – benchTime;

错误说: Uncaught SyntaxError: Unexpected token ILLEGAL

这是完整的脚本:

 var pageLoadDate;
 var benchTime;
 var eventDate;
 var eDiffpl;

 $(document).ready(function() {
   pageLoadDate = new Date();

   $("*").click(function(e) {
       // Stop the function propagating up the DOM tree
       e.stopPropagation();

       // Get the interaction time
       eventDate = new Date();

       // <p data-islink="islink">dduiduihd</p>

       // Check if this is the link we want
       if ($(this).data("footballLink") != undefined) {
         // The right link has been clicked
         benchTime = benchmarkDate();

         eDiffpl = eventDate.getTime() - pageLoadDate.getTime()– benchTime;
         sessionStorage.myTester = Number(sessionStorage.myTester) + eDiffpl;

         // Then move to next page of experiment
         window.location.url = "feedback_page.html";
       }
     } else {
       // An incorrect part of the page has been clicked
       sessionStorage.errorCount = Number(sessionStorage.errorCount) ++;
       console.log(sessionStorage.errorCount);
     }
   });
 });

基准日期函数:

function benchmarkDate()
{
var start_date;
var end_date;

start_date=new Date(); // 1

// 100
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();

// 200
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();

// 300
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();

// 400
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();

// 500
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();

// 600
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();

// 700
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();

// 800
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();

// 900
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();

// 999
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();
end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date(); end_date=new Date();

var diff = (end_date.getTime() - start_date.getTime());

//Debug line below
//alert("start: " + start_date.getTime() + "\nend: " + end_date.getTime() + "\nDiff: " + diff)

return diff;
}
4

1 回答 1

0

我可以立即看到您的代码存在三个问题。你得到错误的那一行,第二个减号不是一个有效的减号。删除它并重新输入。第二。您的闭包不正确,从 click 函数中的 if else 块开始。第三,您没有正确使用 sessionStorage。设置和获取值涉及调用 sessionStorage 上的函数,而不仅仅是添加带有点符号的属性

我不确定您的代码应该做什么,但这是一个没有任何错误的清理版本。

$("*").click(function(e) {
    e.stopPropagation();
    eventDate = new Date();
    if ($(this).data("footballLink") != undefined) {
        benchTime = benchmarkDate();

        // Had some unknown character as a minus sign here.
        eDiffpl = eventDate.getTime() - pageLoadDate.getTime() - benchTime;

        // Setting/Getting values with sessionStorage needs to call
        // getItem and setItem passing keys and values
        // sessionStorage.setItem('key', 'value')
        // sessionStorage.getItem('key')
        var value = parseInt(sessionStorage.getItem('myTester'), 10) + eDiffpl;
        sessionStorage.setItem('myTester', value);
        window.location.url = "feedback_page.html";

    // Fixed your closures here.
    } else {
        var myNumber = parseInt(sessionStorage.getItem('errorCount'), 10);
        myNumber++;
        sessionStorage.setItem('errorCount', myNumber);
        console.log(myNumber);
    }
});

我也无缘无故地把你改成了我更熟悉的Number()parseInt并且还添加了一些变量以使代码比直接在 sessionStorage 上不断地工作更具可读性。但最后那个意外的非法标记是最后一个减号字符是什么字符。除了错误,如果您查看上面的示例,一个减号比另一个长。

于 2016-02-26T14:25:52.567 回答