[ jQuery ] 四角をクリックしてalertを表示
jQueryで四角をクリックしてalertを表示させる
<style>
#box {
width: 100px;
height: 100px;
background-color: #F90;
cursor: pointer;
}
</style>
※cursor: pointer; はマウスが四角の上に来たときに矢印から指にかわる。
<body>
<div id="box"></div>
<script>
$('#box').click(function( ) {
alert('クリックされました');
});
</script>
</body>
作成するときの手順は
①四角を作る
②<style></style>を書く
③jQueryを読み込む
④<script></script>に記述する