本地存储是未定义的jQuery

时间:2019-10-29 12:21:29

标签: javascript jquery

单击按钮时出现未定义的错误。 在这里您可以看到我的jQuery代码:

$(document).ready(function() {
        if(!localStorage.utm){
            localStorage.utm = window.location.search;

        } else if (window.location.search == ""){

        } else if(window.location.search != localStorage.utm){
            localStorage.utm = window.location.search;

        }
    });

$('#signup, #login').click(function(e) {
    e.preventDefault();

    storedUrl = localStorage.utm;
    if(this.href.includes("?")){
        storedUrl = storedUrl.replace("?", "&");
    }

    var finalURL = this.href + storedUrl;
    var linkURL = this.getAttribute("href");

    if(linkURL.includes("app.hirefirst")){
        localStorage.utm = '';
        window.location.href = finalURL;
    } else {

        window.location.href = linkURL;
    }

});

有人可以告诉我我在做什么错吗?

谢谢

0 个答案:

没有答案