3
我只想知道如何将textarea的背景颜色更改为在文本框中键入的颜色。我已经设法做文本的颜色,字体和大小,但以相同的方式做背景似乎不起作用。 我的文本颜色和背景代码:如何使用JavaScript更改textarea的背景颜色
脚本:
function setColor(where, Color)
{
if (where == "backgroundcolour")
document.getElementById('textarea').style.backgroundColor = Color;
if (where == "colourtext")
document.getElementById('textarea').style.color = Color;
}
HTML:
<p>
Card color: <input type = "text" name = "backgroundcolour"
size = "10"
onchange = "setColor('backgroundcolour',
this.value)">
<br>
Text color: <input type = "text" name = "colourtext"
size = "10"
onchange = "setColor('colourtext',
this.value)">
<br>
</p>
<textarea id = 'textarea' name="data" cols="100" rows="10">
</textarea>
它好像我的互联网挡住脚本,以便它wouldnt改变背景
你应该使用jQuery做 – CarneyCode 2011-03-27 12:34:32
文本是如何被输入? – 2011-03-27 12:35:00
我看到多数民众赞成在工作 – 2011-03-27 12:36:42