「jQuery」click()とhover()関数のサンプル
書式1
$( セレクター ).click(function(){
// 処理コード
});
書式2
$( セレクター ).hover(function(){
// 処理コード
});
JSコード
$("div").click(function () {
console.log("click test");
$(this).slideUp();
});
$("div").hover(function () {
console.log("hover test1");
$(this).addClass("hilite");
}, function () {
console.log("hover test2");
$(this).removeClass("hilite");
});
$("div").click(function () {
console.log("click test");
$(this).slideUp();
});
$("div").hover(function () {
console.log("hover test1");
$(this).addClass("hilite");
}, function () {
console.log("hover test2");
$(this).removeClass("hilite");
});
$("div").click(function () { console.log("click test"); $(this).slideUp(); }); $("div").hover(function () { console.log("hover test1"); $(this).addClass("hilite"); }, function () { console.log("hover test2"); $(this).removeClass("hilite"); });
htmlコード
<div>AA</div>
<div>BB</div>
<div>CC</div>
<div>DD</div>