从jquery .offset()获取错误的值 [英] Getting wrong values from jquery .offset()
本文介绍了从jquery .offset()获取错误的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从jquery .offset()中得到了错误的值,我认为这是由于CSS导致的,但是找不到错误.
I'm getting wrong values from jquery .offset(), I think it is because of CSS but cannot find the error.
这是我要获取的偏移量的HTML元素
This is the HTML element I'm trying to get the offset of:
<div id="sedes" class="seccion_in">
</div>
这是CSS
.seccion_in { position:relative; overflow: hidden; width: 100%; height: auto; }
这是jquery:
console.log($("#sedes").offset());
这是工作链接: http://ficm.hacemoscodigo.com/asiste/
感谢您的帮助.
推荐答案
ID必须唯一!
在<div id="nav">
中有#sedes
,在<div id="content">
中有#sedes
.我的猜测是您在nav
中得到了#sedes
的.offset()
.删除/重命名该元素的ID,就可以了.
IDs MUST BE UNIQUE!
You have #sedes
located in <div id="nav">
as well as a #sedes
in <div id="content">
. My guess is you are getting the .offset()
of the #sedes
in your nav
. Remove/rename the ID that element and you should be good.
请确保改用类.
让我知道您是否有任何疑问!
Let me know if you have any questions!
这篇关于从jquery .offset()获取错误的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文