jquery问题 - 它不会相应地改变它

jquery issues - it wont change it accordingly

本文关键字:改变 问题 jquery      更新时间:2023-09-26

我的编码没有正确链接,它的意思是使用 jquery 来检测操作系统并相应地更改链接,但事实并非如此。在我的 HTML 页面中,我将其链接在标题中为

<script src="jsquery.js" type="text/javascript"></script>

现在加载我的 jsquery

$(document).ready(function() {
if (navigator.appVersion.indexOf("Win") != -1) {
    // Computers runs windows
    $("a[href$='.pdf']").each(function() {
        this.href = this.href.replace("Volumes", "KP01DS0194TG");
    });
}
if (navigator.appVersion.indexOf("Mac") != -1) {
    // computer is a Mac
    $("a[href$='.pdf']").each(function() {
        this.href = this.href.replace("KP01DS0194TG", "Volumes");
    });
}

});

然而,在Mac上,它仍然尝试连接到KP01DS0194TG而不是卷 - 它不会改变它 - 如何让它识别操作系统并相应地更改它?

我相信

你不正确地链接到jquery。 我认为它应该是jquery.js而不是jsquery.js。 尝试将标题中的链接更改为以下内容:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>