본문 바로가기

강좌/jQuery

제이쿼리(jQuery) - CSS관련 API

1. DIV 크기 구하기(동적) - 더블클릭시


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

    <head>

<meta http-equiv="content-type" content="text/html;" charset="utf-8" >

        <title> jquery </title>

<style>

   #my{background-color:yellow}

</style>

<script src="http://code.jquery.com/jquery-1.7.2.js"></script>

<script>

   $(document).ready(function (){

//

$("#btn").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="btn" value="위 영역의 크기 구하기" />

</body>

</html>