1. 程式人生 > >jQuery在IE8下的append方法缺陷

jQuery在IE8下的append方法缺陷

想要實現一個效果,動態新增一些樣式到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;}";
}