jQuery UI API - .position ()
หมวดหมู่
วิธีการบรรทุกเกินพิกัด (วิธีการแทนที่) | วิธีการ (วิธีการ) | ยูทิลิตี้ (Utilities)
การใช้
คำอธิบาย: เป็นองค์ประกอบตำแหน่งเทียบกับองค์ประกอบอื่น
ผลตอบแทน: jQuery
รุ่นใหม่: 1.8
.position( options )
参数 | 类型 | 描述 |
---|---|---|
options | Object |
|
UI ที่ jQuery .position()
วิธีการช่วยให้คุณในรูปแบบสัมพัทธ์ (หน้าต่าง) เอกสารหรือตัวชี้องค์ประกอบอื่น (เคอร์เซอร์) / เมาส์ (Mouse) เพื่อหาองค์ประกอบโดยไม่คำนึงถึงการชดเชยเมื่อเทียบกับองค์ประกอบหลัก (offset)
หมายเหตุ: jQuery UI ไม่สนับสนุนสถานที่ซ่อนองค์ประกอบ
นี้เป็นปลั๊กอิน jQuery อิสระและพึ่งพาส่วนประกอบอื่น ๆ ที่ jQuery UI ไม่มี
นามสกุล Plug-in จาก jQuery สร้าง .position () วิธีการ หาก jQuery UI ไม่โหลดโทร .position()
วิธีการไม่เพียงล้มเหลวเพราะวิธีการที่มีอยู่ใน jQuery แต่ก็ไม่ได้คาดว่าจะเกิด
ตัวอย่าง
ง่ายแปล jQuery UI (ตำแหน่ง) ตัวอย่างเช่น
<! Doctype html> <html lang = "th"> <head> <Meta charset = "UTF-8"> <title> .position () ตัวอย่าง </ title> <link rel = "สไตล์ชีต" href = "// code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> <style> .positionDiv { position: absolute; ความกว้าง: 75px; ความสูง: 75px; พื้นหลัง: สีเขียว; } </ style> <script src = "// code.jquery.com/jquery-1.10.2.js"> </ script> <script src = "// code.jquery.com/ui/1.10.4/jquery-ui.js"> </ script> </ head> <body> <div id = "targetElement"> <div class = "positionDiv" id = "position1"> </ div> <div class = "positionDiv" id = "position2"> </ div> <div class = "positionDiv" id = "position3"> </ div> <div class = "positionDiv" id = "position4"> </ div> </ div> <script> $ ( "# Position1") .position ({ ฉัน: "ศูนย์" ที่: "ศูนย์" ของ "#targetElement" }); $ ( "# Position2") .position ({ ฉัน: "บนซ้าย" ที่: "บนซ้าย" ของ "#targetElement" }); $ ( "# Position3") .position ({ ฉัน: "กลางขวา" ที่: "ด้านล่างขวา" ของ "#targetElement" }); $ (เอกสาร) .mousemove (ฟังก์ชั่น (event) { $ ( "# Position4") .position ({ ฉัน: "ซ้าย + 3 ล่าง 3" ของ: เหตุการณ์ ชน: "พอดี" }); }); </ script> </ body> </ html>