jQuery在IE8下的append方法缺陷

来源:互联网 发布:火车票代理软件 编辑:程序博客网 时间:2024/05/21 04:00

想要实现一个效果,动态添加一些样式到style标签中

于是这么写:

<style id="tt"></style>....$("#tt").append(".a{float:left;}");


在ie8下面append方法报错

unexpected call to method or property access


只能用原生的js方法:

var tt= document.getElementById("tt");if(tt.style.cssText){tt.style.cssText = ".a{float:left;}";} 


0 0
原创粉丝点击