jQueryオブジェクト22



イベントとthis - 成功



ソースコード【 HTML 】

<!DOCTYPE html>
<html lang="ja"><head>
<meta charset="UTF-8">
<title>イベントとthis - 成功</title>

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

<style>

body {
background-color: #FCF;
}

.clickTest {
width: 300px;
height: 100px;
background-color: #9FC;
}

</style>
</head>
<body>

<div class="clickTest">div!</div>
<div class="clickTest">div!</div>
<div class="clickTest">div!</div>
<div class="clickTest">div!</div>
<div class="clickTest">div!</div>

<script>
$(function() {
$('.clickTest').click(function() {
$(this).text('クリックされました');
});
});
</script>

</body>
</html>

ブラウザで表示【 Chrome



  • クリックで表示