zoukankan      html  css  js  c++  java
  • 文档对象的操作

    1. 操作内容:
       A. innerHTML:设置/获取对象起始和结束标签内的内容,包括里面的 html

       B. innerText:适用于IE,用来设置/获取起始和结束标签内的文本内容,除去 html 标签

       C. textContent: 与 innerText,只是适用于 FF

    2. 操作属性
       A. 直接操作
          对象.属性
          对象.属性 = 值

       B. 获取getAttribute("属性")/设置 setAttribute("属性", "值");

    3. 操作样式
       A. 行内样式
          对象.style.属性     //用于获取
          对象.style.属性 = 值
     
       B. CSS 样式操作
          1. 通过 id 更改  var.id = idname;
          2. 通过类名更改: var.className = classname
         以上适合于批量更改
     4. 更改/设置/获取某个属性值
       IE:
       document.styleSheets[下标].rules[下标].style.属性 [= 值]
       doucment.styleSheets: 获取 样式表列表集合
       document.styleSheets[下标].rules: 获取 指定样式表下 css 样式规则的列表集合
       document.styleSheets[下标].rules[下标]:获取 指定样式表下 css 样式指定的规则

       FF:
       document.styleSheets[下标].cssRules[下标].style.属性 [=值]

    5. 动态添加删除 css 样式 规则
      FF:符合 W3C
      增加样式:
      document.styleSheets[下标].insertRule("选择器{属性:值}", 位置)
      如: document.styleSheets[0].insertRule("#div1{200px}", 0)
     表示在指定的样式前增样式

     删除样式:
     document.styleSheets[下标].deleteRule(位置)

     IE:
     document.styleSheets[下标].addRule("选择器", "属性:值", 位置)
     document.styleSheets[下标].removeRule(位置)

    6. 行内样式和 css 通用方式:(只用于获取,不能用于设置)
       IE:
       对象.currentStyle.属性
       FF:
       getComputedStyle((对象, null).属性)

  • 相关阅读:
    BZOJ 1191 HNOI2006 超级英雄hero
    BZOJ 2442 Usaco2011 Open 修建草坪
    BZOJ 1812 IOI 2005 riv
    OJ 1159 holiday
    BZOJ 1491 NOI 2007 社交网络
    NOIP2014 D1 T3
    BZOJ 2423 HAOI 2010 最长公共子序列
    LCA模板
    NOIP 2015 D1T2信息传递
    数据结构
  • 原文地址:https://www.cnblogs.com/lin3615/p/3182937.html
Copyright © 2011-2022 走看看