私のサイト構造の簡単な概要:
ajax を介してローカルに保存された php ファイルを提供するメイン インデックス php。(乱雑に聞こえる場合は、それが原因です)
ajax をロードしたスクリプトから呼び出すメイン インデックス ファイルに関数があり、IE を除くすべての場所で正常に動作します。
意味のあるエラー メッセージが表示されません。
Invalid argument. jquery-1.4.2.min.js, line 144 character 219
注:この質問は私の前の質問に直接関連しています: jQuery $el.position(...) is undefined
jQuery 関数 (index.php)
// nav
var $el;
var leftPos;
var newWidth;
var $mainNav = $("#navbar ul");
$mainNav.prepend("<li id='magic-line'></li>");
var $magicLine = $("#magic-line");
function navBar() {
// console.log('navBar start');
function checkActive() {
// console.log('check active');
// Hide magic line if nav bar has no active element
if($('#navbar ul').children('.active').length < 1) {
$magicLine.hide();
//console.log($('#navbar ul').children('.active').length < 1);
//console.log($('#magic-line'));
//console.log('hide');
}
else {
$magicLine.stop().animate({
left: $magicLine.css('left', $(".active a").css('left')),
width: $magicLine.width($(".active a").width())
});
}
}
checkActive();
$magicLine
.width($(".active a").width())
.css("left", $(".active a").position().left)
.data("origLeft", $magicLine.position().left)
.data("origWidth", $(".active a").width());
// $("#navbar ul li a").hover(function() {
// apply hover function to li instead and just just el to it's child
$("#navbar ul li").hover(function() {
// $el = $(this);
$el = $(this).children('a');
// leftPos = $el.position().left;
leftPos = $el.parent().position().left;
newWidth = $el.width();
$magicLine.stop().animate({
left: leftPos,
width: newWidth
}, 600);
}, function() {
if($('#navbar ul').children('.active').length < 1) {
$magicLine.stop();
checkActive();
} else {
$magicLine.stop().animate({
left: $magicLine.data("origLeft"),
//width: $magicLine.data("origWidth")
width: $magicLine.width($(".active a").width())
}, 600);
}
});
}
これは、次のようにするだけで、すべてのスクリプトで呼び出されます。
navBar();
しかし、何らかの理由でIEで問題が発生しており、その理由については理由がわかりません。