jQuery如果位置等于检查 [英] jQuery if position equals check
本文介绍了jQuery如果位置等于检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何检查位置是否相等?
How can i check if position equals?
试图达到这样的目标:
if($(element).css({ left: "468px"}) == 468)
else
推荐答案
尝试一下:
if($(element).position().left == 468)
.position()
方法具有2个属性,顶部和左侧.这使您相对于父元素处于顶部和左侧.如果需要相对于文档的位置,请使用.offset()
:
The .position()
method has 2 properties, top and left. This gives you top and left relative to the parent element. If you need the position relative to the document, use .offset()
:
if($(element).offset().left == 468)
这篇关于jQuery如果位置等于检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文