情况如下
<button class="stately" id="stately" value="1" onclick="updateFlag(this);">牢固</button>class="stately" 是我调用的一个style样式(html) ,这个样式里面有个属性color.我现在遇到的问题就是 我希望在updateFlag(this) 这个js函数里面如何获取到这个样式的颜色的值?谢谢!!
<button class="stately" id="stately" value="1" onclick="updateFlag(this);">牢固</button>class="stately" 是我调用的一个style样式(html) ,这个样式里面有个属性color.我现在遇到的问题就是 我希望在updateFlag(this) 这个js函数里面如何获取到这个样式的颜色的值?谢谢!!
解决方案 »
- HelloWord.java的运行
- java代码如何判断文件类型为execl2003和execl2007
- 急+怪:定义了两个单独List类全局变量,操作一个List,另外一个List的值也跟着发生变化
- 读取SYBASE数据库出现的奇怪问题?读取字符数据时只能读出258个字节来!
- 请问如何制作java的安装程序,什么软件比较好用,谢谢
- 文本文件的保存?
- 关于JAVA自带的压缩解压类
- 新手求助。动态数组问题、
- java 写hello world 程序??
- 小弟想编写一个非常简单的javascript程序,可惜语法不熟,请赐教!!
- 请教一个问题,关于读取文件,传递的是对象,附代码...在线等
- 如何知道哪些类调用了某个类的方法
var color = obj.style.color;
alert(color);
}
用JQUERY
先下JQUERY.JS
var str_color = $('stately').attr('color');
alert(str_color);
先下JQUERY.JS
var str_color = $('#stately').attr('color');
alert(str_color);
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
</head><style type="text/css">
.background { background-color:Gray; width:150px; }
.word { color:red; font-size:12px; height:100px; }
</style><script type="text/javascript">if (!window.getComputedStyle) {
window.getComputedStyle = function(element) {
if (!element) throw 'element is null or undefined';
if (!element.currentStyle) throw 'element unsupport currentStyle';
var cs = element.currentStyle;
!cs.getPropertyValue && (cs.getPropertyValue = function(css) {
return this[css];
});
return cs;
};
}window.onload = function() {
var content = document.getElementById('content');
var color = window.getComputedStyle(content).getPropertyValue('background-color');
alert(color);
}</script><body>
<div id="content" class="background word">test</div>
</body>
</html>