「jQuery入門」on()とbind()でイベントを実行する方法

2018年5月3日

1.JSコード
<script>
$(document).ready(function(){
$(“#div_AA").on(“click",function(){
$(this).css(“background-color","green");
});
$(“#div_BB").bind(“click",function(){
$(this).css(“background-color","green");
});
});
</script>
</head>
<body>

2.htmlコード
<div id="div_AA" style="border:2px solid black;">This is some text.
<p>Click to set background color using the <b>on() method</b>.</p>
</div><br>

<div id="div_BB" style="border:2px solid black;">This is some text.
<p>Click to set background color using the <b>bind() method</b>.</p>
</div>

JavaScript

Posted by arkgame