这段代码的问题在于它试图使用jQuery的load()函数来加载一个文件,但是在此之前并没有引入jQuery库。所以需要先引入jQuery库,然后再加载class.html文件。修改代码如下:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
    function menuInfo(a) {
        $("#info").load(a);
    }
    menuInfo("class.html");
</script>
<a href="javascript:void(0)" onclick="menuInfo('class.html')" class="nav-link active">这个为什么不能调用class.html文件,怎么让它在这段代码之前被加载。</a>

这样就可以正确加载class.html文件了。

script function menuInfoa $#infoloada; menuInfoclasshtml;script a href=javascriptvoid0 onclick=menuInfoclasshtml class=nav-link active这个为什么不能调用classhtml文件怎么让它在这段代码之前被加载。

原文地址: https://www.cveoy.top/t/topic/i9Z1 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录