合成事件

jQuery 有两个合成事件hover()方法和toggle()方法。
1.hover()方法用于模拟光标悬停事件。
2.toggle()方法可以切换元素的可见状态。

$(document).ready(function () {
//hover方法 鼠标移入和移出
$(“div”).hover(function(){
$(this).prev().css(“color”,“red”);
},function(){
$(“h3:first”).css(“color”,“blue”);
});
// toggle方法(显示和隐藏)
$("#btnShow").click(function(){
$(“h3:last”).toggle();
});
});

猜你喜欢

转载自blog.csdn.net/weixin_43750327/article/details/84800038