jQuery | javascript | CSS

44.jQuery - Width와 Height값 크기 구하기 ( 06.CSS )

Godffs 2009. 11. 11. 13:31
반응형
jQuery 에서 Width와 Height 값의 크기 구하는 예제입니다.

01.WidthHeight.htm

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

<head>

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

     <style type="text/css">

          #my { background-color:Lime; }

    </style>

   

    <script src="../jQuery/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>

 

<!--

    my영역에 대해서 길이를 구해서 값을 동적으로 가져온다.

    더블클릭시 실행 (실행창의 크기)

-->


결과화면

[그림44-1]



반응형