js 修改html元素样式,如何使用JS将样式修改为HTML元素(使用CSS外部样式)?

b5601b5c2b981916d32493a3c353015b.png

幕布斯6054654

像这样做:function selectHome() {  console.log("test");  document.getElementsByClassName("home")[0].style.backgroundColor = "green";}.greyRect {  height: 150px;  width: 1350px;  background-color: #D3D3D3;}h1 {  text-align: center;}h2 {  text-align: center;}.home {  box-sizing: border-box;  width: 80px;  height: 35px;  line-height: 2;  position: relative;  left: 350;  color: white;}.casinocraps {  background-color: grey;  box-sizing: border-box;  width: 120px;  height: 35px;  text-align: center;  line-height: 2;  position: relative;  left: 460;  bottom: 50;  color: white;}.tictactoe {  background-color: grey;  box-sizing: border-box;  width: 90px;  height: 35px;  text-align: center;  line-height: 2;  position: relative;  left: 600;  bottom: 100;  color: white;}.bingo {  background-color: grey;  box-sizing: border-box;  width: 80px;  height: 35px;  text-align: center;  line-height: 2;  position: relative;  left: 700;  bottom: 150;  color: white;}.concentration {  background-color: grey;  box-sizing: border-box;  width: 100px;  height: 35px;  text-align: center;  line-height: 2;  position: relative;  left: 800;  bottom: 200;  color: white;}footer {  text-align: center;  line-height: 4;  position: relative;  top: 125;  right: 15;  height: 70px;  width: 1365px;  background-color: #D3D3D3;}.border {  height: 50px;  width: 100px;  border: 4px solid green;  background-color: #555;  position: relative;  top: 20;  left: 100;}.rectangle {  height: 50px;  width: 100px;  background-color: #555;  position: relative;  top: 50;  left: 100;}

           

Assignment 1

   

Home Page

         

        Home     

 

    Casino Craps 

 

    Tic-Tac-Toe 

 

    Bingo 

 

    Concentration 

    Footer 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值