标签:name document orange this range 点击 pre 事件 nbsp
两次点击事件进行切换
var toggle = (function () { var a = true; return function (fn1, fn2) { a = !a; var toggler = function () { if (a) { return fn1; } else { return fn2; } }; return this.onclick = toggler(); } })();
使用方法:
var div = document.getElementsByTagName("div")[0]; div.onclick = function () { toggle(function () { div.className = "red"; }, function () { div.className = "orange"; }); };
标签:name document orange this range 点击 pre 事件 nbsp
原文地址:http://www.cnblogs.com/loveyunk/p/6604098.html