[WidthHeight.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; }

    </style>

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

    <script type="text/javascript">

        $(document).ready(function () {

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

                var msg = $('#my').width() + ", " + $('#my').height();

                window.alert(msg);

            });

        });

    </script>

</head>

<body>

    <div id="my">

        <p>jQuery</p>

        <p>Ajax</p>

    </div>

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

</body>

</html>

 



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

 


[실행결과]

--> 처음 실행할 때 웹 브라우저의 크기를 일정크기로 조절하고 '위 영역의 크기 구하기'버튼을 마우스로 클릭하면, 아래그림과 같이 '메시지박스'에 노란색영역의 "<div>태그의 사이즈"가 출력된다.





--> 이번에는 웹 브라우저의 크기를 다르게 맞추고(-> 늘리고) '위 영역의 크기 구하기'버튼을 마우스로 클릭하면, 아래그림과 같이 '메시지박스'에 노란색영역의 "<div>태그의 사이즈"가 위의 그림과 다르게 출력된다.






 

 

 

Posted by holland14
: