select问题:select的字体颜色我会 “动态” 改变,可是背景色,字的大小,或者怎样给字加粗呢?

laosan 2003-08-21 03:24:46
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>select问题</title>
</head>

<body>
<form name="form1" method="post" action="">
<select name="select1" size="10">
<option value="a">aaaaaaa</option>
<option value="b">bbbbbbb</option>
<option value="c">ccccccc</option>
</select>
</form>

</body>
<script language="JavaScript">
<!--
//改变字体颜色(以下代码正确)
form1.select1.options[0].style.color="red";
//改变背景颜色(以下代码错误)
//form1.select1.options[1].style.background-color="green";
//改变大小

//加粗

-->
</script>
</html>
...全文
706 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
laosan 2003-08-21
  • 打赏
  • 举报
回复
谢谢两位!
fason 2003-08-21
  • 打赏
  • 举报
回复
sorry:一时大意,楼上正确
bencalie 2003-08-21
  • 打赏
  • 举报
回复
Sorry,更正一下,字体和加粗都针对select

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>select问题</title>
</head>

<body>
<form name="form1" method="post" action="">
<select name="select1" size="10">
<option value="a">aaaaaaa</option>
<option value="b">bbbbbbb</option>
<option value="c">ccccccc</option>
</select>
</form>

</body>
<script language="JavaScript">
<!--
//改变字体颜色(以下代码正确)
form1.select1.options[0].style.color="red";
//改变背景颜色(以下代码错误)
form1.select1.options[1].style.backgroundColor="green";
//改变大小
form1.select1.style.fontSize="40px";
//加粗
form1.select1.style.fontWeight="bold";
-->
</script>
</html>
fason 2003-08-21
  • 打赏
  • 举报
回复
form1.select1.options[1].style.backgroundColor="green";
form1.select1.options[1].style.fontWeight="bold";
form1.select1.options[1].style.fontSize="20px"
bencalie 2003-08-21
  • 打赏
  • 举报
回复
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>select问题</title>
</head>

<body>
<form name="form1" method="post" action="">
<select name="select1" size="10">
<option value="a">aaaaaaa</option>
<option value="b">bbbbbbb</option>
<option value="c">ccccccc</option>
</select>
</form>

</body>
<script language="JavaScript">
<!--
//改变字体颜色(以下代码正确)
form1.select1.options[0].style.color="red";
//改变背景颜色(以下代码错误)
form1.select1.style.backgroundColor="green";
//改变大小
form1.select1.style.fontSize="40px";
//加粗
form1.select1.style.fontWeight="bold";-->
</script>
</html>
fason 2003-08-21
  • 打赏
  • 举报
回复
form1.select1.options[1].style.backgroundColor="green";
form1.select1.options[1].style.fontWeight="bold";
form1.select1.options[1].style.fontSize="20px"

87,907

社区成员

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

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