开发者

getting div current placement

开发者 https://www.devze.com 2022-12-14 06:53 出处:网络
How can I get the div\'s current postion with jQueryor divs current placement wit开发者_如何转开发h jQueryvar position = jQuery(\'#myelement\').position();

How can I get the div's current postion with jQuery or divs current placement wit开发者_如何转开发h jQuery


var position = jQuery('#myelement').position();
alert(position.left);
alert(position.top);


Check out the "CSS" section of the jQuery docs, in particular the #offset function.


Do you mean position on your web page? This depends on the browser you are using. They handle code in a different way sometomes...

You can check your app via Firebug in Firefox or Webdeveloper Toolbar in Internet Explorer for getting the right values.


try position function.

var pos=$("#ID_OF_DIV").position();

alert("TOP: " + pos.top +"\r\nLEFT: " + pos.left);
0

精彩评论

暂无评论...
验证码 换一张
取 消