簡體   English   中英

jQuery Uncaught TypeError:無法讀取未定義的屬性“ top”

[英]jQuery Uncaught TypeError: Cannot read property 'top' of undefined

我不斷收到以下錯誤: Uncaught TypeError: Cannot read property 'top' of undefined

問題與此行有關: 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); } }); 

我對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); } }); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM