動態創建style標籤樣式
操作步驟:
- 創建style標籤 var stylee=document.createElement(‘style’);
- 給標籤添加屬性 stylee.type = ‘text/css’;
- 給標籤添加id stylee.id = ‘styleId’;
- 設置要添加的字符串 var sHtml = ‘.un-points .un-point-bullet{background-color:#ffffff;}’;
- 給標籤添加HTML stylee.innerHTML = sHtml;
- 最後在head標籤裏面添加style標籤 document.getElementsByTagName(‘head’).item(0).appendChild(stylee);
實例代碼:
var stylee=document.createElement('style');
stylee.type = 'text/css';
stylee.id = that.config.styledot;
var sHtml = '.un-points .un-point-bullet{background-color:#ffffff;}';
stylee.innerHTML = sHtml;
document.getElementsByTagName('head').item(0).appendChild(stylee);