js 操作样式属性

<script>
        var div = document.querySelector('div');
        div.onclick = function() {
            this.style.backgroundColor = 'purple';
            this.style.width = '250px';
        }
    </script>
  var btn = document.querySelector('.close-btn');
        var box = document.querySelector('.box');
        btn.onclick = function() {
            box.style.display = 'none';
        }
原文地址:https://www.cnblogs.com/ericblog1992/p/13050750.html