作者:皮蓬 | 来源:互联网 | 2023-10-12 21:05
像素格式问题效果不太显著,正确效果为单击后自身变色其余恢复默认
效果预览
html代码
<button>按钮button><button>按钮button><button>按钮button><button>按钮button><button>按钮button>
css代码
无
js代码
<script>var button &#61; document.getElementsByTagName(&#39;button&#39;)for (var i &#61; 0; i < button.length; i&#43;&#43;) {button[i].onclick&#61;function (){for (var j &#61; 0; j < button.length; j&#43;&#43;) {button[j].style.background&#61;&#39;&#39;}this.style.background&#61;&#39;pink&#39;}}
</script>