通过onclick事件修改元素样式
style代码:
div {
width: 200px;
height: 200px;
background-color: pink;
margin: 100px auto;
}
<div></div>
Script代码:
var div = document.querySelector('div');
div.onclick = function() {
this.style.backgroundColor = 'red';
this.style.width = '100px';
}
版权属于:Cyril
转载时须注明出处及本声明梦溪博客-自由、开放的个人学习、交流的博客猫扑小程序 影视导航