外部JS文件中的jQuery [英] JQuery in external JS file
本文介绍了外部JS文件中的jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我的html页面加载时,我正在尝试执行一些JavaScript.调用顶部方法populateSelectWithDates(),但不会调用jquery部分.有什么想法吗?
I am trying to execute some JavaScript when my html page loads. The top method populateSelectWithDates() is called, but the jquery portion does not. Any ideas?
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文件中,请确保按以下顺序包含脚本:
In your HTML file, make sure you are including the scripts in this order:
<!-- 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>
这篇关于外部JS文件中的jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文