- obj = ev.target ? ev.target :ev.srcElement ; //w3c与ie获取事件元素方法不同
-
//添加CSS var addCSS = function(cssText) { var styleEl = d.createElement('style'); styleEl.type = "text/css"; d.getElementsByTagName('head')[0].appendChild(styleEl); //先appendChild,否则hack失效 if (styleEl.styleSheet) { styleEl.styleSheet.cssText = cssText; } else { styleEl.appendChild(d.createTextNode(cssText)); } }
看到这个我在想为什么不采用yui里的YAHOO.util.Get.css(url, opts)呢?不管怎么样,这段代码能兼容现有的浏览器总是不错的。就像以前看长天在群里说的那样,不要一看到这样就认为人家的代码就很差。每段代码都是为了实现某一目的而产生的。