多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
### 事件 ~~~ var test = document.getElementById("test"); test.onclick = function(){ ~~~ ![](https://box.kancloud.cn/e030672cfb0a54c0746d7c8e68f4ed0e_170x58.png) var test 是节点 document.getElementById("test")获取节点 this指执行事件的当前对象 ~~~ this.style.color ="red"; ~~~ 点击颜色变红 ![](https://box.kancloud.cn/fffa5793797754359dfcd41292af59a8_143x61.png) ~~~ this.innerHTML = "change" ~~~ 点击文字改变 ![](https://box.kancloud.cn/e1b1df0fc4b7ffecbea61eeb9246af41_141x50.png) ~~~ if(this.style.color=="red"){ this.style.color="#333" }else{ this.style.color="red" } ~~~ 点击红黑切换 ~~~ this.style.color=(this.style.color==="red")?"#333":"red"; ~~~ 三目运算实现红黑切换 三个等号表示连类型也完全一致 \[为真执行第一个指令,假执行冒号后的指令\]