jQueryオブジェクト24



値や内容をセットする/取得する



ソースコード【 HTML 】

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>値や内容をセットする/取得する</title>

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

<style>

body {
background-color: #FCF;
}

#div1 {
width: 300px;
height: 200px;
background-color: #9FC;
}

</style>
</head>
<body>

<div id="div1">div!</div>

<script>
$(function() {
var div1 = $('#div1');
alert(div1.width());
alert(div1.height());
alert(div1.css('font-size'));
});
</script>

</body>
</html>

ブラウザで表示【 Chrome

  • 各指定された情報の表示