컴

width(), height() 메서드를 이용하여 가로크기, 세로 크기 알아내기

· 2014-09-22 (월) 05:57:31 · 4958

width()는 요소의 가로값, height()는 요소의 세로값을 구할 수 있는 메서드입니다.

<style>
  div{width:100px;height:200px;border:1px solid red;}
 </style>


 <script>
  $(document).ready(function(){
   var w = $('div').width();
   var h = $('div').height();   
   $('p').text(w + ' / ' + h);
  }); 
 </script>
</head>
<body>
 <div>컨텐츠</div>
 <p></p>

 

|
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
jQuery 14-10-17 조회 7,665
jQuery 14-10-17 조회 1.8만
jQuery 14-10-17 조회 8,968
PHP 14-10-17 조회 6,007
PHP 14-10-17 조회 5,216
jQuery 14-10-13 조회 3,953
JavaScript 14-10-13 조회 4,029
jQuery 14-10-13 조회 4,283
기타 14-10-10 조회 8,260
기타 14-10-10 조회 4,315
기타 14-10-10 조회 4,742
기타 14-10-10 조회 3,343
기타 14-10-10 조회 3,736
jQuery 14-10-07 조회 9,214
jQuery 14-09-24 조회 3,481
PHP 14-09-23 조회 3,611
jQuery 14-09-23 조회 4,151
PHP 14-09-22 조회 3,424
jQuery 14-09-22 조회 4,959
jQuery 14-09-22 조회 6,090
jQuery 14-09-22 조회 3,616
jQuery 14-09-22 조회 3,509
PHP 14-09-19 조회 3,929
PHP 14-09-19 조회 3,362
jQuery 14-09-19 조회 4,002
PHP 14-09-19 조회 3,764
PHP 14-09-18 조회 4,615
jQuery 14-09-18 조회 1.2만
jQuery 14-09-18 조회 8,844
jQuery 14-09-18 조회 3,547