How to achieve different texts in Textarea different colors? If it is the style that controls Textarea, all texts are a color;
If the text is put in the mark, it will not work because the mark will not be explained, and it is treated as text.
I found a method on the Internet:
I copy the code to TXT and modify it to HTML format. Test a role. HTML is as follows:
Copy code code as follows:
<html>
<head>
<Title> FF </Title>
<Script language = "javascript">
Function Ta ()
{{
// --------------------------------------------------------------------
var ofont1 = document.createElement ("font");
var ovext1 = document.createtextNode ('China');
ofont1.style.color = "Black";
form1.topic.appendchild (ofont1);
OFONT1.appndChild (OTEXT1);
// --------------------------------------------------------------------
var ofont2 = document.createElement ("font");
var ovext2 = document.createtextNode ('People's');
OFONT2. Style.Color = "#FF3322";
form1.topic.appendchild (ofont2);
OFONT2.APPENDCHILD (OTEXT2);
// --------------------------------------------------------------------
var ofont3 = document.createElement ("font");
var ovext3 = document.createtextNode ('Liberation/R');
OFONT3. Style.Color = "#00eeff";
form1.topic.appendchild (ofont3);
OFONT3.APPENDCHILD (OTEXT3);
// --------------------------------------------------------------------
var ofont4 = document.createElement ("font");
var team = "Haha's soldiers";
var ovext4 = document.createtextNode (text);
ofont4.style.color = "#00ee00";
form1.topic.appendchild (ofont4);
OFONT4.appndchild (OTEXT4);
}
</Script>
</head>
<body>
<form name = "form1" action = "" method = "Post">
<textarea id = "test" name = "topic" rows = "10" color = "40"> </textarea>
<input type = "Button" value = "Submit" onClick = "TA ()">
</form>
</body>
</html>
Copy the above code to a txt, and change the txt file to the HTML file.