-3

我正在学习 JavaScript,并计划制作一个 Chrome 扩展程序。我正在制作一个年龄计算器。我已经开发了一些代码。我被困在如何在外部 JavaScript 文件中使用 jQuery?

if (ageYears > 0) {
    document.write(ageYears +" year");
    if (ageYears > 1) document.write("s");
        if ((ageMonths > 0)||(ageDays > 0)) document.write(", ");
    }
    if (ageMonths > 0) {
        document.write(ageMonths +" month");
        if (ageMonths > 1) document.write("s");
        if (ageDays > 0) document.write(", ");
}
if (ageDays > 0) {
    document.write(ageDays +" day");
    if (ageDays > 1) document.write("s");
}

清单.json

{
    "name": "Age Calculator",
    "description": "This application gives you a calculation of how old are you today, since the day you were born.",
    "version": "0.1",
    "manifest_version": 2,

    "app": {
        "background": {
            "scripts": ["background.js"]
          }
    },
    "icons": { "128": "calendar-128.png" }
    "author" : "Miral Kumbhani"
}
4

1 回答 1

-1

只需将所有代码放入外部 JavaScript 文件,然后在链接 jQuery.js 的主文件中链接文件,即

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="FILENAME.js"></script>
于 2017-09-15T11:26:24.557 回答