用JS怎么实现点击一个文字变成红色,再点击其它文字,原本变成红色的文字恢复原样,被点击的文字变成红色!!
1 回答

lucky__star
TA贡献1条经验 获得超0个赞
function text(){ console.log(document.getElementById('id1').style.color); if(document.getElementById('id1').style.color=="red"){ document.getElementById('id1').style.color="green"; } else{ document.getElementById('id1').style.color="red"; } } 那个写错了,,,是一个等号
添加回答
举报
0/150
提交
取消