因此,当我单击<p>家庭班级的标签时,我希望它将颜色更改为绿色,但不起作用,请问为什么。单击可以很好地注册(因为console.log(“ test”)可以很好地显示),但是其余更改颜色的功能将无效。这是我的css,html和js代码(该js代码包含在HTML中,因此它不是外部文件或其他任何文件):
.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; …Run Code Online (Sandbox Code Playgroud)