One div i set the height in css using top:-26px;
. I have other divs other places where i'd like to align with that div. I notice in jquery writing .css('top')
gets me my css and not the y coord of the div. How do i get the absolute x,y position using javascript?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
Use jQuery(element).offset()
Hope it helps.
For example
Try this code:
It will return an object with
left
andtop
variables.If you use JQuery try
offset()
method:Cross browser safe down to IE 8, possibly even 7 or 6:
Short and fast and no jQuery needed.
You can use
jQuery(element).offset().top
Hope it helps.
I will give you the vanilla solution.. don't complain.. add a [0] to your element and it's fixed! :P hope this helps.