2016-07-06 16 views
0

の「上部」私は、次のエラーを取得しておいてください。Uncaught TypeError: Cannot read property 'top' of undefinedjQueryのキャッチされない例外TypeError:プロパティを読み取ることができません未定義

問題は、この行に関する:posY = pos.top - $(window).scrollTop(),

それは実際にそれが少しあるものを損傷していないが、見る痛み。

var postest = inf.offset().top;を使用してコンテンツを取得しようとしましたが、代わりに起こったのはオフセットエラーです。

アイデアをいただければ幸いです。

$(document).on("mouseenter", ":has('.infotip.ifixed')", function() { 
 
    var inf = $(".infotip.ifixed"); 
 
    if (inf.length) { 
 
    var itheight = $(this).children(".infotip").innerHeight(), 
 
     pos = $(this).children(".infotip").parent().offset(), 
 
     posY = pos.top - $(window).scrollTop(), 
 
     posX = (pos.left - $(window).scrollLeft()) + 190, 
 
     accuheight = (posY - itheight) + 150, 
 
     divPos = { 
 
     left: posX, 
 
     top: accuheight 
 
     }; 
 
    $(this).find(".infotip.ifixed").css(divPos); 
 
    } 
 
});

+4

'$(この).children( " infotip")。親()。' 'undefined'です)(オフセット。 –

+0

これらの行のどれが失敗しますか?あなたはブラウザのコンソールでそれを見ることができますか? – ddb

+0

@ddbどの行に失敗したのかについては、質問を参照してください。 – DCdaz

答えて

0

infのための私の定義が間違っていました。

$(document).on("mouseenter", ":has('.infotip.ifixed')", function() { 
 
    
 
    var inf = $(this).children(".infotip").parent(); 
 
    
 
    if (inf.length) { 
 
    var postesty = inf.offset().top, 
 
     postestx = inf.offset().top; 
 
    
 
    var itheight = $(this).children(".infotip").innerHeight(), 
 
     posY = postesty - $(window).scrollTop(), 
 
     posX = (postestx - $(window).scrollLeft()) + 190, 
 
     accuheight = (posY - itheight) + 150, 
 
     divPos = { 
 
     left: posX, 
 
     top: accuheight 
 
     }; 
 
    
 
    $(this).find(".infotip.ifixed").css(divPos); 
 
    } 
 
});

関連する問題