jquery position() method
Translation results:
position
UK[pəˈzɪʃn] US[pəˈzɪʃən]
n. Position, direction; status, position; attitude; status
vt .Place; put... in a proper position; position...; garrison troops
jquery position() methodsyntax
Function: The position() method returns the position (offset) of the matching element relative to the parent element. The object returned by this method contains two integer properties: top and left, measured in pixels. This method only works on visible elements.
Syntax: $(selector).position()
jquery position() methodexample
<html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ x=$("p").position(); alert("Left position: " + x.left + " Top position: " + x.top); }); }); </script> </head> <body> <p>This is a paragraph.</p> <button>获得 p 元素的位置坐标</button> </body> </html>
Click the "Run instance" button to view the online instance
Popular Recommendations
- Search- Search Insert Position
- Bitcoin Keeps Improving Its Position – $70K A Strong Possibility
- Crypto Whale With $26.47M WBTC Position Faces Potential Liquidation on Compound
- Bitcoin (BTC) Price Plunges 6.5% as Arthur Hayes Opens Short Position, Targets Sub-$50K
- Chainlink (LINK) Confirms Its Leadership Position in the Crypto Ecosystem by Displaying Exceptional Development Activity
- Dogecoin (DOGE) Price Prediction: DOGE Reclaims Position Above Downward Trend Line Indicating a Potential Trend Reversal