> For the complete documentation index, see [llms.txt](https://dnjsdl678.gitbook.io/jquery/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnjsdl678.gitbook.io/jquery/undefined-3/offset.md).

# position() / offset()

> $("선택자").position().left;\
> $("선택자").position().right;\
> $("선택자").position().top;\
> $("선택자").position().bottom;

> $("선택자").offset().left;\
> $("선택자").offset().top;

```markup
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jQueray11 position()/offset()</title>
    <style>
        div {line-height: 40px; text-align: center; background-image: linear-gradient(120deg, #84fab0 0%, #8fd3f4 100%);}
        .circle1 {position: absolute; left: 100px; top: 400px; width: 40px; height: 40px; border-radius: 50%;}
        .circle2 {position: absolute; right: 100px; bottom: 400px; width: 40px; height: 40px; border-radius: 50%;}
    </style>
</head>
<body>

    <div class="circle1">1</div>
    <div class="circle2">2</div>

    <button class="btn1">circle1</button>
    <button class="btn2">circle2</button>
    <button class="btn3">position1</button>
    <button class="btn4">position2</button>
    <ul>
        <li><span>position().left : </span><span class="pl">0</span></li>
        <li><span>position().top : </span><span class="pt">0</span></li>
        <li><span>position().bottom : </span><span class="pb">0</span></li>
        <li><span>position().right : </span><span class="pr">0</span></li>
        <li><span>offset().left : </span><span class="ol">0</span></li>
        <li><span>offset().top : </span><span class="ot">0</span></li>
        <li><span>width() : </span><span class="wi">0</span></li>
        <li><span>height() : </span><span class="he">0</span></li>
    </ul>

    <!-- script -->
    <script src="jquery.min_1.1.24.js"></script>
    <script>
      $(".btn1").click(function(){
        const pl = $(".circle1").position().left;
        const pt = $(".circle1").position().top;
        const pb = $(".circle1").position().bottom;
        const pr = $(".circle1").position().right;
        const ol = $(".circle1").offset().left;
        const ot = $(".circle1").offset().top;
        const wi = $(".circle1").width();
        const he = $(".circle1").height();

        $(".pl").text(parseInt(pl));
        $(".pt").text(parseInt(pt));
        $(".pb").text(parseInt(pb));
        $(".pr").text(parseInt(pr));
        $(".ol").text(parseInt(ol));
        $(".ot").text(parseInt(ot));
        $(".wi").text(parseInt(wi));
        $(".he").text(parseInt(he));
      });

      $(".btn2").click(function(){
        const pl = $(".circle2").position().left;
        const pt = $(".circle2").position().top;
        const pb = $(".circle2").position().bottom;
        const pr = $(".circle2").position().right;
        const ol = $(".circle2").offset().left;
        const ot = $(".circle2").offset().top;
        const wi = $(".circle2").width();
        const he = $(".circle2").height();

        $(".pl").text(parseInt(pl));
        $(".pt").text(parseInt(pt));
        $(".pb").text(parseInt(pb));
        $(".pr").text(parseInt(pr));
        $(".ol").text(parseInt(ol));
        $(".ot").text(parseInt(ot));
        $(".wi").text(parseInt(wi));
        $(".he").text(parseInt(he));
      });

      $(".btn3").click(function(){
          $(".circle1").offset({top:70, left:200});
      });
      $(".btn4").click(function(){
          $(".circle2").offset({top:270, left:20});
      });
    </script>

</body>
</html>
```

![](/files/-ML5RcOGUogaCvly14Ax)

231p 예제 숙제

{% hint style="info" %}
자바스크립트에서는 다음과 같이 offsetTop 메서드를 사용한다.
{% endhint %}

```markup
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>offsetTop</title>
    <style>
        .box1 {
            width: 250px;
            height: 50px;
            background-color: lightseagreen;
            margin-top: 420px;
            border-radius: 100px;
            text-align: center;
            line-height: 50px;
        }

        .box2 {width: 250px;
            height: 50px;
            background-color: #ccc;
            margin-top: 10px;
            border-radius: 100px;
            text-align: center;
            line-height: 50px;}
    </style>
</head>
<body>
    <div class="box1">이 박스의 offsetTop 값은 ? </div>
    <div class="box2"></div>

    <script>
        document.querySelector(".box2").innerText = document.querySelector(".box1").offsetTop;
    </script>
</body>
</html>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dnjsdl678.gitbook.io/jquery/undefined-3/offset.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
