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';
        }
posted @ 2020-06-05 17:03  EricBlog  阅读(183)  评论(0)    收藏  举报