3 回答

TA贡献1801条经验 获得超16个赞
如果将文本传递给选择器并传递除黑色以外的其他颜色,则代码将起作用,因为文本的默认颜色为黑色。
function green()
{
document.getElementById("text").style.color="green";
}
<textarea id="text" rows="10" cols="100" onClick="green();"></textarea>

TA贡献1842条经验 获得超21个赞
添加textarea样式:
<html>
<head>
<title>AUTO EMAIL</title>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 50%;
}
td, th {
border: 1px solid #dddddd;
text-align: center;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
textarea {
color: green;
}
</style>
</head>
<body>
<table align=center>
<tr>
<td colspan="2">
<textarea id="text" rows="10" cols="100" ></textarea>
</td>
</tr>
</table>
</body>
</html>
添加回答
举报