[OuterWidthAndHeight.htm]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>검색된 요소의 크기 구하기</title>

    <style type="text/css">

        #my {

            background-color:Yellow; border:2px solid gray; position:absolute;

            padding:10px; z-index:0; margin:10px;

            top:50px; left:50px;

            width:200px; height:200px;

    </style>

    <script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(document).ready(function() {

            $('#btnSize').mouseover(function () {

                // outerHeight() : 마진을 제외한 영역의 크기

                alert("outerHeight : " + $("#my").outerHeight());

                // outerHeight(true) : 마진을 포함한 영역의 크기

                alert("outerHeight(true) : " + $("#my").outerHeight(true));               

                alert("outerWidth : " + $("#my").outerWidth());

                alert("outerWidth(true) : " + $("#my").outerWidth(true));

            });

        });

    </script>

</head>

<body>

    <div id="my">

        <p>jQuery</p>

        <p>Ajax</p>

    </div>

    <input type="button" id="btnSize" value="위 영역의 크기 구하기" />

</body>

</html>

 



-------------------------------------------------------------------------------------

 


[실행결과]


--> 첫 화면. outerHeight() : 마진을 제외한 영역의 크기. (기본영역크기: 200px + (padding(10px) * 2) + (border(2px) * 2) = 224)
 





--> 위의 그림에서 '확인'버튼을 눌렀을 때의 화면. outerHeight(true) : 마진을 포함한 영역의 크기  (기본영역크기: 200px + (padding(10px) * 2) + (border(2px) * 2) + (margin(10px) * 2) = 244)




--> 위의 그림에서 '확인'버튼을 눌렀을 때의 화면.




--> 위의 그림에서 '확인'버튼을 눌렀을 때의 화면.



 

 

 

Posted by holland14
: