<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>标题</title>
    <!--    <script type="text/javascript"src="../jquery-3.4.1.min.js"></script>-->
</head>
<body>
<input type="button" id="open" value="开灯"/>
<input type="button" id="close" value="关灯"/>
<script src="jquery-3.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {//页面加载完毕之后需要执行的代码写在这个匿名函数里面
        $("#open").click(function () {//向指定id的元素上面添加事件
            $("body").css("background", "white");//将body的背景颜色变成白色
        });

        $("#close").click(function () {
            $("body").css("background", "black"); //将body的背景颜色变为黑色
        });
    });

</script>


</body>
</html>

 

相关文章:

  • 2022-01-16
  • 2021-11-26
  • 2021-08-16
  • 2021-11-29
  • 2021-10-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-09
  • 2022-12-23
  • 2021-04-24
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
相关资源
相似解决方案