外部 JS 文件中的 JQuery

JQuery in external JS file

本文关键字:JQuery 文件 JS 外部      更新时间:2023-09-26

当我的html页面加载时,我正在尝试执行一些JavaScript。顶部方法填充SelectWithDates()被调用,但jquery部分没有。 有什么想法吗?

function doInitialPopulation() {
    //This works
    populateSelectWithDates();
    //This does not
    $(document).ready(function() {
        alert('ok');
    //Credit to: http://www.pewpewlaser.com/articles/jquery-tablesorter
        //  Adds sort_header class to ths
        $(".sortable th").addClass("sort_header");
        //  Adds alternating row coloring to table.
        $(".sortable").tablesorter({widgets: ["zebra"]});
        //  Adds "over" class to rows on mouseover
        $(".sortable tr").mouseover(function() {
            $(this).addClass("over");
        });
        //  Removes "over" class from rows on mouseout
        $(".sortable tr").mouseout(function() {
            $(this).removeClass("over");
        });
    });
}

在 HTML 文件中,请确保按以下顺序包含脚本:

<!-- first include jQuery -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- then include your script(s) -->
<script src="YOUR_SCRIPT.js" type="text/javascript"></script>

我没有看到任何用处$(document).ready(function() {尝试删除它。并让我们知道警报("确定")是否有效。我们也可以看到函数populateSelectWithDates()吗?