gpt4 book ai didi

javascript - 如何用html加载外部js文件

转载 作者:行者123 更新时间:2023-12-01 02:55:30 26 4
gpt4 key购买 nike

我使用以下方法将 html 内容加载到我的索引中,

$("#home-btn").click(function() {
$("#content").load("views/plant.html");
});

它正确加载 html 内容,但我使用了一些与 html 相关的外部 js 文件并链接了相关的外部 js 文件添加到我的索引 html 中。问题是,我加载的 html 内容中缺少外部 js 的效果。我该如何修复它?

最佳答案

使用 html 文件引用外部 js 文件,如下面的代码所示。

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="Scripts/externalFile.js"></script>
</head>
<body>
</body>
</html>

关于javascript - 如何用html加载外部js文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46726462/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com