gpt4 book ai didi

jquery - 在 Chrome 中获取自定义 HTML 标签的高度和宽度

转载 作者:行者123 更新时间:2023-11-28 03:33:05 25 4
gpt4 key购买 nike

我在 iframe 中创建了自定义 html 标签。当指针悬停在该元素上时,我尝试从父元素获取元素高度和宽度。有人知道如何获得该元素的高度和宽度吗?它在 Firefox 中有效,但在 chrome 中它总是返回 0。

示例:

  1. 在 iframe 中我使用了这样的自定义标签:<item></item>
  2. 我像这样从父级访问该元素:
$('#iframe').load(function(){
$('#iframe').contents().find("item").hover(
function(){
var height = $(this).height();
var width = $(this).width();
console.log("Height : "+height+" | Width : "+width);
// it's always return 0 in chrome
},
function(){

},
);
});

我认为问题是因为 chrome 无法识别自定义 html 标签。但我不太确定。感谢您的帮助。

最佳答案

文档类型必须有效,如 <!DOCTYPE html >并将显示 block 放在“元素”元素上

关于jquery - 在 Chrome 中获取自定义 HTML 标签的高度和宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16350359/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com