Firebug正在给出错误:
TypeError: $(...) is null
$('#menu img').hover(
Run Code Online (Sandbox Code Playgroud)
我不知道为什么。看似有问题的脚本是当光标悬停在图像上时替换图像的脚本:
$(document).ready(function()
{
var storeNormalPath;
$('#menu img').hover(
function()
{
storeNormalPath = $(this).attr('src');
var imgArray = $(this).attr('src').split('.jpg');
$(this).attr('src', imgArray[0]+'Hover.jpg');
},
function()
{
$(this).attr('src', storeNormalPath);
}
).click (function()
{
//empty now
});
});
Run Code Online (Sandbox Code Playgroud) 你可以在http://jsfiddle.net/twsx7/9/看到我的js(以及相关的html和css)
我正在进行调整以使用Blackboard Learn 9.1(因此,如果有人体验过学习管理系统,或者使用调整构建块,他们可能已经知道为什么我会遇到这个问题).
我正在进行的更改包括检查应用的课程主题,然后根据该类添加一个类,以便对表进行样式设置以匹配主题.
当我在我们的服务器上运行它时,我得到错误$(...) 在到达var theme_id = $(".current")时为空.at("id"); .JS的其余部分工作(请注意,JS的顶部通常是包含在页面上的另一个文件,无法将其链接到jsfiddle,因为它在经过身份验证的服务器上)
我对这个文件的贡献是(以及代码失败的地方):
第242行
$unitMap.addClass(getTheme());
Run Code Online (Sandbox Code Playgroud)
381 - 385行
function getTheme() {
var theme_id = $(".current").attr("id"); // error occurs this line
var theme = $("#"+theme_id).find("a").html();
return theme.toUpperCase();
}
Run Code Online (Sandbox Code Playgroud)
这是我第一次尝试使用jQuery,因此我担心的是我使用了错误的语法来编写代码所使用的jQuery版本.
当您选择包含调整时,我在代码中找到以下内容:
<script src='/webapps/qut-tweakbb-BBLEARN/jquery.js' type='text/javascript'></script><script src='/webapps/qut-tweakbb-BBLEARN/jquery.tweakSetup.js' type='text/javascript'></script>
Run Code Online (Sandbox Code Playgroud)
jsFiddle顶部的代码来自jquery.tweakSetup.js
我希望我只是用错了标记的jQuery的版本(虽然我不能缝找什么原来写的代码版本)的任何建议将不胜感激.