如何使用jQuery更改背景颜色?
要使用jQuery更改背景颜色,请使用jQuerycss()属性。我们将使用jQueryon()和css()方法更改鼠标悬停时的背景颜色。
示例
您可以尝试运行以下代码,以了解如何使用jQuery更改背景颜色:
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("body").on({
mouseenter: function(){
$(this).css("background-color", "gray");
},
mouseleave: function(){
$(this).css("background-color", "red");
},
dblclick: function(){
$(this).css("background-color", "yellow");
}
});
});
</script>
</head>
<body>
<p>Double click and move the mouse pointer to change the background color.</p>
</body>
</html>热门推荐
8 甄嬛传祝福语简短
10 新年探亲祝福语简短精辟
11 生日祝福语古朴简短独特
12 送菜的祝福语简短霸气
13 老师节祝福语的简短
14 毕业祝福语简短英语小学
15 新年祝福语简短创意兄弟
16 英文简短唯美祝福语大全
17 今年节日祝福语简短
18 求助短信生日祝福语简短