Webデザイナーへの道しるべ | suge1040's diary

Webデザイナーになる事を目指しフェリカテクニカルアカデミーで勉強していましたsuge1040によるブログです。

[ jQuery ] 四角をクリックしてalertを表示

jQueryで四角をクリックしてalertを表示させる

 

f:id:suge1040:20140415145532j:plain

<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>に記述する