如何获得样式? window.event.toElement.className 用在onmouseover事件里可以得到当前文字使用的样式式名 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 若要是获得align,font等属性呢?又该如何获得 <script>function getstyle(obj){mystyle=obj.style.cssText;for(i=0;i<mystyle.split(";").length;i++)if(mystyle.split(";")[i].indexOf("FONT")>-1)alert(mystyle.split(";")[i]);}</script><input type=text style="text-align:center;font:12pt;color:red;background:yellow" onchange=getstyle(this)> <div id=test style="font-size:2">asdfasdf</div><script>alert(test.style.fontSize);</script> obj.style.textAlignobj.style.fontSizeobj.style.fontFamilyobj.style.color等等,使用对应的属性 obj.currentStyle.textAlignobj.currentStyle.fontSizeobj.currentStyle.fontFamilyobj.currentStyle.color to bencalie(Bencalie) :你所说的 obj 是什么,如何获得? 一个例子:<font id=id1 style="color:#ff0000">asf</font><script>alert(id1.style.color);</script>其它就差不多了 我的没有楼上老兄所说的id而且我也没有办法添加那个id to bencalie(Bencalie) :你所说的 obj 是什么,如何获得? 我可以用document.selection获得选中的文本,如果没有选中,只是光标在那个地方,用什么方法获得光标在文本中的位置呢? 关闭页面后自动清除cookie 关于多个不同ID的DIV 需调用不用 JS函数 的问题、、 关于jquery ajax接收字符串的问题 关于防止表单多次提交的问题(在线等待) 有代码 希望高手帮助改下,急急急~~~~ javascript怎样将简体中文EncodeUrl为百度那样的格式? 关于location的一个问题: 一个函数重名问题,同一页文件中和独立js文件中的区别 事件处理,急急!!回答就散分!! 为什么我这段js在火狐,ie下都可以使用,在谷歌浏览器就不行??? 这段程序只能循环显示两幅图,请高手帮忙改成可以显示多幅图的,谢谢。 请教暂停程序的函数(急救中!)
又该如何获得
function getstyle(obj)
{
mystyle=obj.style.cssText;
for(i=0;i<mystyle.split(";").length;i++)
if(mystyle.split(";")[i].indexOf("FONT")>-1)
alert(mystyle.split(";")[i]);
}
</script>
<input type=text style="text-align:center;font:12pt;color:red;background:yellow" onchange=getstyle(this)>
alert(test.style.fontSize);
</script>
obj.style.fontSize
obj.style.fontFamily
obj.style.color
等等,使用对应的属性
obj.currentStyle.fontSize
obj.currentStyle.fontFamily
obj.currentStyle.color
你所说的 obj 是什么,如何获得?
<script>
alert(id1.style.color);
</script>其它就差不多了
而且我也没有办法添加那个id
你所说的 obj 是什么,如何获得?