如何javascript获取css中的样式
obj.style.height只能获取行间样式,但是我们要怎么获取写在css文件中的样式呢?
首先我们要用一个新的方法currentStyle.这个方法由current和style两个单词组成意思是:目前的样式.也就是加载css文件后取出来的样式.
currentStyle的用法是:元素.currentStyle.属性名
下面我们开始获取如图div的width样式,那我们就需要这样写:
var w=document.getElementById('div').currentStyle.width;
alert(w);
在IE下调试,看是不是可以得到正确的宽度了
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAT8AAAB2CAIAAAAx5APsAAAMFUlEQVR4nO2dv2sbyxqGXblLkSrNaYSEA7nGYJwi+IrbWIkxx4UTg8AQDJJCwMVJZVgwB5E0AhsCSnEKYbu1i8NpAgdXdmlSCAz6A9zp7/AtZnZ3ZnZmd3Z3pNW3+8JTxOv17tjRo3d2fnxaqtVXQAb+s7kGXFH4/yZRlgpvAQAgG7AXAKrAXgCoUrC9r48ez66ezvpe4X8IAMgxL3v3b8+uno725YON9wc/ns6uns6ubrcbOS7e+2vycD95uJ/8+2crz3UAIEV2e18fPZ79OH/dWKnVV7b7T8G/9WjtdZK9gbqwF1SM7PZu933rWITGG2iwNz+98/vJw/1lr/g/JQBzJqu9jfcHP55Ojt7X6iu1hneUmJ8ztReRCypJenuZqyYEh3mvWCC0V7mIYn7z/ORK0xXf7j+dXT0eNKWDsBdUltnYGw5HZbKX/7gsKvuRiNKwF1SWzD1n7yiwsXl+ovSK92/PFNNMPWdTr3v/9uzK75nHXKHRucRgFagqWe1tnp8E2bh/K+UkT055EiitvZGk3e5L12x9/ccfav7n69vi/44AzJ/U9kafZgUeD5q+vUoXN629ylNu5DTYC8As7NU9oKa3l3XIeedZifeAt3/ePNxPzjuF/x0BmD8Ze86vjx6Dfqy6VEPXc97uP6W2V8jwmNUgGLUClSWjveFTqK6fzFz1Z4PD8ed09vL3iMeDpnekjGAJwF5QWXLYy4zVLrRiE7YCJ/1baVyaDUpHUBVlI9v925iF0LAXVJZM9op5GzvlE0auMqtkaa8f4zELuWAvqCzk9/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+u82w9x55lU6dc6pRLnmSQSSRxrIW8S442e5Zl67l0nc+c89ylmL2Sco0835KFa0XUr1aVe/2O5Mf+n7O6bKWZrviBmi+aa96EXropiL2y19xzFwKhn67z7FkOmULI0c6c89yF0LPezGvW+7kbBV90ccE7IX4M9OTujXhTEK8Vre+b+VxD0uhfipkLAZlCyNHOXkm5hpRr6r2uV7t2qTqKu6/Fa4uNftPG+N0ygr5/py9Kt2rPfUvhW7JGv5nPNSRkGmnmCXS+JQutnnUzd2K9x53sM+abkvpK4yPx/ej7at6EvkJ2ekvZ9/r+piBeK0Q/MrkQ3EZEvdSNXrer9krxY8XKXdvg3VXwTogf2G1MV7FVA73ZvZl+r/iRycc44AZ0s3UT92rvanXIPgPxNuiNuzdW9w9l+b4k35fkuyIJeQGQScc44OT4k9ei37p2Z8aWu6/F09HblP2HSvFDxVjuzfp7JwAy4RgH3HgJtJWdxLba3c19quKHorcre4O+qrtXP1TU91qMFwCZaIwDbn4VDOiUanctdyfF08t+kL7NCYBMJebjb4E+str9Ln4Ees39NolxTM36EQdjfkWMl4lS7S7k7oD4Ye4p9Dcft8v9JwDiQB7NykdDd6F1J8UPQ29DX0+ZuEcciu2LQnkRHZftOvHj0KecAIgjGfliOc7pGYj/Iv2IC+M4m2csHieDa+M4AN+JR5AnCcQj/grEI/4KxCP+CsQj/grEI/4KxCP+CsQj/sr/A8lrzHdoz9nuAAAAAElFTkSuQmCC" alt="" />
IE可以了然后我们换个火狐试试,无论我怎么刷新都没有弹出我希望的200px,f12调试一下,原来如此,火狐不支持currentStyle方法.
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAApcAAABmCAIAAAARXy1TAAAeuklEQVR4nO2dbXAUx5nHfYntutSVz3fOXVUck+SOuKJUKWAsnyITK8ghCILRO0gCZB0YsBCyhQBpJTvZ5ZC0CMsyC2glOBav5dUb+CzAQMLZixNS8rkcVxkslbO5D5CKorhUNkS5xFins+wq34eel+6Z7tnZmdXujvirfkWtVj2z8/R0P/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m8Lr1Km46Dp5ncw7J//TzcJXcVFRur5ZfGPxcmTUwZzm5lFxDjzf56AHkEB0om38g9nAekadfh3H6jZhY6g4cD43qYoLtjCh4nMHE7vUYJYw+tYXhVgfHtO/E/UBNsOMOr71BcwRblIVBwDMBqKd79Qn6V0HgDWg4gAAAIBTgYoDAAAATgUqDgAAADgVqDgAAADgVOKs4gAAAABIGFBxAAAAwKlAxQEAAACnAhUHAAAAnApUHAAAAHAqUHEAAADAqUDFAQAAAKcCFQcAAACcClQcAAAAcCpQcQAAAMCpQMUBAAAApwIVBwAAAJwKVBwAAABwKlBxAAAAwKlAxQEAAACnAhUHAAAAnApUHAAAAHAqUHEAAADAqUDFAQAAAKcCFQcAAACcClQcAAAAcCpQcQAAAMCpQMUBAAAApwIVBwAAAJwKVBwAAABwKlBxAAAAwKlAxQEAAACnAhUHAAAAnApUHAAAAHAqUHEAAADAqUDFAQAAAKcCFQcAAACcClQcAAAAcCpQcQAAAMCpQMUBAAAApwIVBwAAAJwKVBwAAABwKlBxAAAAwKn8P5fAUXmq56EbAAAAAElFTkSuQmCC" alt="" />
火狐和Chrome支持的是另外一个方法:getComputedStyle,大概意思就是获取完成的样式.
用法:getComputedStyle(元素,false).属性名
同2,我们的代码应该这样写:
var w=getComputedStyle(document.getElementById('div1'),false).width;
alert(w);
现在不报错了,也能正常的获取了
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAFbCAIAAADJExmZAAATWUlEQVR4nO3dzW4jV3oGYF5HBrYlEjYgoG9keqlF3wNhoFc2YA1g92ay6B5JZP0cIBOtAnRvjAQJMJsgjWyCGEYAr5O1LsD3kAVJNdWi/nhU4jkfH+IFRqOux+L0TH1DUlXfO2q7vmn7tktdn5qub9q+61PXp6btm67v+tR2qWn7tuv7PrVdmrdd26W+TyAIgmDT9qOm7U/PZimllNJs3p7P5ouvz2fz2bxdfH16NmvaLqXUdund6VnbpZQSCIIgeHo2G10dPW+6rk/9YtC2fd+nrk/zpmvafvG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kXKhMVp4BhqjJ6tRefPV6Oq9/+Vlha9GCzmthoBKRMqFxmjhGeZXTEdHq6H5+Ri9OB4dnXy8OF689KxujBZyWg0BlYiUC43RwjPAq9FrLzI/nhwdnyzeuq/e7386eMPjqabqkJ+N7v60GgIqESkXGqOFxz31D48SkcoW+oeBxmjhMUYfHiUilS30DwON0cJjjD48SkTuuRQAHAgao4XHGH14lIgsJ3QtC/3DQGO08BijD48SkcpuzAoDjdHCY4w+POFvBi10Lz9ojBaeXVUfP0+e9u9KiUhlC/3DQGO08Ox80tU1Rgs5rYaASkTKhcaohIkSkcoW+oeBxqiEiRKRmwdsM+DBx0JjVMJEiUhlC/3DQGNUwkSJSGqqWugfBhqjEiZKRCq7hisMNEYlTMJfN7o8el7YXn7QGJUwUSJyz92m4EDQGJUwUSJS2UL/MNAYlTBRIlLZQv8w0BiVMFEi0qeqFvqHgcaohIkSke7+HwAqERG5PUpEKlvoHwYaoxImSkQqW+gfBhqjEiZKRO65FAAcCBqjEiZKRJYTupaF/mGgMSphokSkshuzwkBjVMIk/M2ghe7lB7/74ft//p9/2/kJIJKZf/qP9ydv/lTIaTUEVCJSLuz+sf/uh++nHh6VP37880/n/9AUcloNAZWIgCAIZkElIiAIgkpEQBAEdweViIAgCCoRAUEQVCICgiBYKVQiAoIgmAWViIAgCGZBJSIgCIJZUIkICIJgFlQiAoIgmAWViIAgCGZBJSIgCIJZUIkICIJgFlQiAoIgmAWViIAgCGZBN4OCIAjm3gxa6F5+EATBKqASERAEwSyoRAQEQTALKhEBQRBUIgKCILg7qEQEBEEwCyoRAUEQzIKuGwVBEMy9bnR59LywvfwgCIJVQCUiIAiCWVCJCAiCYBb8f1XJCaclYpbmAAAAAElFTkSuQmCC" alt="" />
经过修改,我就完成了最终代码
var div = document.getElementById("div");
div.addEventListener("click",function(){
try{
//非IE浏览器
alert(getComputedStyle(div,false).width);
}catch(ew){
//IE浏览器使用方式
alert(div.currentStyle.width);
}
},false);
如何javascript获取css中的样式的更多相关文章
- javascript获取css中的样式值
<body> <input type="button" id="btn" value="启动"/> <img ...
- js获取css中的样式
众所周知,obj.style只能够获取 <div id="a" style="width:100px;"></div> 结构上的样式 如 ...
- 重温JavaScript获取CSS样式的方法(兼容各浏览器)
众所周知,CSS样式有三种类型:行内样式.内部样式和外部样式,JavaScript获取CSS样式时分为两种情况:行内样式获取法 和 非行内样式获取法 . 一.行内样式获取相对简单,通过element. ...
- javascript获取元素的计算样式
使用css控制页面有4种方式,分别为行内样式(内联样式).内嵌式.链接式.导入式. 行内样式(内联样式)即写在html标签中的style属性中,如<div style="width:1 ...
- JavaScript获取地址栏中的参数
JavaScript获取地址栏中的参数 1.获取地址栏中的参数 (1)若地址栏中的地址是: http://10.124.36.56:8080/CMOD/index.jsp?name=you&p ...
- Javascript获取数组中的最大值和最小值的方法汇总
比较数组中数值的大小是比较常见的操作,下面同本文给大家分享四种放哪广发获取数组中最大值和最小值,对此感兴趣的朋友一起学习吧 比较数组中数值的大小是比较常见的操作,比较大小的方法有多种,比如可以使用 ...
- CSS中的样式层叠机制Cascade
CSS中的样式层叠机制Cascade 一.样式冲突 样式冲突是CSS渲染过程要解决的一个关键问题,样式冲突主要由两个原因造成: 元素包含了不同对象所赋予的样式:浏览器.用户.作者.其中,浏览器样式 ...
- JavaScript获取css 行间样式,内连样式和外链样式的方式
[行间样式获取] <div id='div1' style="backgroud:red">测试</div> <script> var odiv ...
- flask模板应用-javaScript和CSS中jinja2
当程序逐渐变大时,很多时候我们需要在javaScript和CSS代码中使用jinja2提供的变量值,甚至是控制语句.比如,通过传入模板的theme_color变量来为页面设置主题色彩,或是根据用户是否 ...
随机推荐
- 【译】延迟加载JavaScript
[译]延迟加载JavaScript 看到一个微信面试题引发的血案 --[译] 什么阻塞了 DOM?中提到的一篇文章,于是决定看下其博客内容,同时翻译下来留作笔记,因英文有限,如有不足之处,欢迎指出.同 ...
- linux 中c/c++实现终端命令行命令
在终端中可以从用下面命令获得帮助: man system 在c/c++代码中实现和在终端中输入的命令行一样的效果,以命令(audacious -p &)为例,该代码实现用audacious在后 ...
- Xcode版本太低引发的bug,xcode各种版本下载方式详解
问题描述: mac系统10.9.5 .之前用的xcode 是5.1.接sdk时,一直报错,编译不过去.最后发现原因是xcode版本太低导致的. 于是去网上找xcode历史版本下载.因为系统版本原因,我 ...
- [html5] 学习笔记- 编辑API之Range对象(二)
本节继续介绍range对象的方法,包括cloneRange,cloneContents,extraContents,createContextual,createContextual-Fragment ...
- git命令实战之血泪记录
注意: 本文章所写所有命令均在Git命令行窗口执行!非cmd窗口! 打开git命令行窗口步骤为:到项目根目录下执行bash命令行操作:右键点击Git Bash Here菜单,打开git命令窗口,不是c ...
- android Android性能优化之如何避免Overdraw
什么是Overdraw? Overdraw就是过度绘制 怎么来消灭overdraw呢?总的原则就是:尽量避免重叠不可见元素的绘制,基于这个原则,我们大概可以想出以下几招: 第一招:合理选择控件容器 ...
- linux gdb基本概念
GDB是一个功能强大的调试器,它是一个自由软件,能够用在许多UNIX平台上.它同时也是Linux系统中的默认调试器.GDB已被移植到许多其他的计算机平台上,并且能够用于调试嵌入式实时系统.一般来说,G ...
- C语言 extern学习1
没有头文件时,通过本文件内的函数声明来确定定义域,实现功能: //单文件测试 #include <stdio.h> /* 经测试,C语言环境下子函数默认是void型:所以可省略不写 为严谨 ...
- MVC中登录页图片验证码总结
直接上代码了 using System;using System.Collections.Generic;using System.Drawing;using System.Drawing.Imagi ...
- C++inserter
C++的迭代器适配器中常用的有插入迭代器(Inser Iterator).流迭代器(Stream Iterator)和逆向迭代器(Reverse Iterator)等! 本文主要是介绍插入迭代器(In ...