如何改变.redText #pid 里面的CSS属性?

yfgcq 2007-10-24 10:25:24
<STYLE TYPE="text/css">
.redText {color: red;}
#pid {color: red;}
</STYLE>

<P id="redText" CLASS="redText">11</p>
<P id="pid">22</p>

<script language="javascript" type="text/javascript">
function getpid()
{
var redTextobj=document.getElementById("redText");
var pidobj=document.getElementById("pid");
alert(redTextobj.style.color);
alert(pidobj.style.color);
怎么改变redTextobj、pidobj这个两对象现在的color属性?

}
getpid()
</script>
...全文
83 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
CutBug 2007-10-24
  • 打赏
  • 举报
回复
<STYLE TYPE="text/css" > 
.redText {color: red;}
#pid {color: red;}
</STYLE >
<P id="redText" CLASS="redText" >11 </p >
<P id="pid" >22 </p >
<input type="button" onclick="test()" value=" test " />
<script language="javascript" type="text/javascript" >
function test()
{
var ss = document.styleSheets[0];
var rules = ss.rules?ss.rules:ss.cssRules
for(var i=0;i<rules.length;i++)
{
if(rules[i].selectorText=="#pid")
{
rules[i].style.color="yellow";
}
}


}
</script>
<html> <head> <meta http-equiv="Content-Language" content="zh-cn"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <meta http-equiv="refresh" content="15; url=http://www.onlinedown.net/"> <title>华军软件园下载文件说明</title> <style type="text/css"> body {background-image: url(http://www.onlinedown.net/newhuagg/bj2.gif); background-repeat: repeat-x; background-color: #B2E8F5; } input{-webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box;} .hj {border: 1px none #55A0E6; line-height: 20px; color: #0000; text-decoration: none; line-height: 20px; color: #000000; font-weight: normal; font-size: 14px; } .zi {font-size: 20px; color: #000;height: 50px;line-height: 50px; text-decoration: none; font-weight: 600; } .zi span{color:red;} </style> <link rel="stylesheet" type="text/css" href="http://src.onlinedown.net/Public/css/newstyle/reset.css"> <link rel="stylesheet" type="text/css" href="http://src.onlinedown.net/Public/css/newstyle/headfoot.css"> [removed] var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?1057fce5375b76705b65338cc0397720"; var s = document.getElementsByTagName("script")[0]; s[removed].insertBefore(hm, s); })(); [removed] </head> <body> 找软件用软件,到华军软件园! 软件发布 <!-- 搜索 -->
蓝屏日志查看器<html> <head> <meta http-equiv="Content-Language" content="zh-cn"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <meta http-equiv="refresh" content="15; url=http://www.onlinedown.net/"> <title>华军软件园下载文件说明</title> <style type="text/css"> body {background-image: url(http://www.onlinedown.net/newhuagg/bj2.gif); background-repeat: repeat-x; background-color: #B2E8F5; } input{-webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box;} .hj {border: 1px none #55A0E6; line-height: 20px; color: #0000; text-decoration: none; line-height: 20px; color: #000000; font-weight: normal; font-size: 14px; } .zi {font-size: 20px; color: #000;height: 50px;line-height: 50px; text-decoration: none; font-weight: 600; } .zi span{color:red;} </style> <link rel="stylesheet" type="text/css" href="http://src.onlinedown.net/Public/css/newstyle/reset.css"> <link rel="stylesheet" type="text/css" href="http://src.onlinedown.net/Public/css/newstyle/headfoot.css"> [removed] var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?1057fce5375b76705b65338cc0397720"; var s = document.getElementsByTagName("script")[0]; s[removed].insertBefore(hm, s); })(); [removed] </head> <body> <!-- 搜索 -->
<!--搜索 begins--> <form class="fr" name="fs" action="http://search.onlinedown.net/search_list.php" method="get" id="cse-search-box" target="_blank"> <input type="hidden" id="searchsid" name="searchsid" value="1">
<input type="text" class="form-control fl" id="demo" name="searchname" value="请输入软件名称,如:百度杀毒" autocomplete="off">
    </form>
    <!-- 导航 -->
    华军软件园(www.onlinedown.net)软件说明

    您下载的该文件来自于华军软件园(www.onlinedown.net)
    what you are downloading are from Onlinedown Download Site:(www.onlinedown.net)

    使用前请您先阅读以下条款:
    please read the following items before using:

    1.本站仅对原软件包“依样”打包,未做过任何改动,但不保证所提供软件或程序的完整性和安全性。
    1.Our website only pack up the original software without any altering, but wecannot
    guarantee?the integrality and safety of the software or program.

    2. 请在使用前查毒 (这也是您使用其它网络资源所必须注意的) 。
    2.please check the virus before using-that's what you must pay attention to while usingother net resources.

    3. 由本站提供的程序对您的网站或计算机造成严重后果的本站概不负责。
    3.we are not responsible for the severe result of your website or computer caused by the program supplied by our website. 

    4. 转载本站提供的资源请勿删除本说明文件。
    4.when you transfer the resources of our website, please do not delete this instruction.
     
    </body> </html>

    87,997

    社区成员

    发帖
    与我相关
    我的任务
    社区描述
    Web 开发 JavaScript
    社区管理员
    • JavaScript
    • 无·法
    加入社区
    • 近7日
    • 近30日
    • 至今
    社区公告
    暂无公告

    试试用AI创作助手写篇文章吧