先选择你想切换的div 给它绑定一个点击事件就行div.onclick=function(){div.style.backgroundColor='red'}
div:active{background-color:green;}div:active{background-color:red;}