<!DOCTYPE html><html><meta http-equiv="content-type" content="text/html" charset="UTF-8"><link rel="stylesheet" type="text/css" href="/html/csstest1.css" /><head><br charset="utf-8"><title>悯农</title></head><body><p id="A">更换颜色</p>
<script> var a=0; function genghuan(){ if(a++%2==0){ document.getElementById("A").style.color="green" }else{ document.getElementById("A").style.color="red" } }</script><button type="button" onclick="genghuan()">干这里</button><noscript>抱歉,你的浏览器不支持 JavaScript!</noscript>
</body></html>-------------------------------------------
第一次点击
第二次点击
第三次点击
依次循环