摘要: 往往我们需要在 JS 中动态添加事件,这就涉及到浏览器兼容性问题了,以下谈及的几种方法,我们也常常混合使用。方法一、setAttributevar obj = document.getElementById("obj");obj.setAttribute("onclick", "javascript:alert('测试');");这里利用 setAttribute 指定 onclick 属性,简单,很好理解,但是:IE 不支持,IE 并不是不支持 setAttribute 这个函数,而是不支持用 setAttribut 阅读全文
posted @ 2011-06-10 15:13 快樂桃子° . 阅读(633) 评论(1) 推荐(0) 编辑