利用js动态创建 <style>
2013-12-30 14:01
441 查看
实例:
参考:http://webchina110.cn/?p=328
var nod = document.createElement(“style”), str = “body{background:#000;color:#fff} a{color:#fff;text-decoration:none;} a:hover{color:red;text-decoration:underline}”; nod.type=”text/css”; if(nod.styleSheet){ //ie下 nod.styleSheet.cssText = str; } else { nod.innerHTML = str; //或者写成 nod.appendChild(document.createTextNode(str)) } document.getElementsByTagName(“head”)[0].appendChild(nod);
参考:http://webchina110.cn/?p=328
相关文章推荐
- 利用js动态创建<style>
- 利用js动态创建 <style>
- <细节>动态创建二维数组
- JS动态生成<style>
- <div style="display:none">中更改的内容使用js无法获取
- 利用javascript动态创建表格<!--进阶-->
- js 创建<a>标签 并触发
- JS -- <table> 行号自增,前端动态生成的<tr>
- Js初学笔记之<创建对象的五种方式>
- extjs4手工创建Chart 前台js包错 Error: Invalid value for <svg> attribute height="-Infinity"
- < Unity 3D专栏 >动态创建对象,并渲染贴图,动态添加删除脚本
- url 参数传递中文乱码问题 即<a href> 利用 js 的 encodeURI解决中文乱码问题
- IE6通过点击 <a href="javascript:void(0);"></a>方式动态创建iframe无法显示
- php+js+mysql设计的仿webQQ-<6>JS创建聊天窗口
- js如何验证日期是否有效<包括日期是否为空,是否符合格式2013-04-17,及是否是一个合法的日期>
- JS正则表达式匹配<div><style>标签
- jsp 静态引入<%@ include %> 动态引入<jsp:include> 区别
- <input type = "submit"> 提交方式和用js的form.submit()有什么区别?
- Note On <You Don't Know JS - Scope and Closures>
- <02>创建Window窗口