zoukankan      html  css  js  c++  java
  • 读写样式属性值

    js读写样式
    .style.只能行内样式 就是写在标签内的style=""内的样式属性---可写

    IE中使用的是obj.currentStyle方法,
    而FF是用的是getComputedStyle 方法
    计算的样式值--只读,可通过.style方法写
    即使行内没有显式的写出

    function getDefaultStyle(obj,attribute){
    // 返回最终样式函数,兼容IE和DOM,设置参数:元素对象、样式特性
    return obj.currentStyle?obj.currentStyle[attribute]:document.defaultView.getComputedStyle(obj,false)[attribute];
    }//属性名加引号

    window.getComputedStyle(obj,false)[attribute];也行

    obj.style.cssText 可读写

    obj.style.cssText="30px;height:100px"

  • 相关阅读:
    7.Mongodb安全性流程
    6.Mongodb索引
    5.Mongodb聚合
    8-进程管理
    7-安装包管理
    6-文件系统
    5-权限用户组
    27-ATM+购物车程序
    26.本章小结
    名词解释
  • 原文地址:https://www.cnblogs.com/everwangJS/p/4566651.html
Copyright © 2011-2022 走看看