I'm trying to create something like a little editor in javascript, but I don't understand why the .style doesn't work..
Thanks in advance for the help!
This is my code:
<html>
<head>
<title>Hello World!</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
<div>
<textarea cols="30" rows="1" id="title1">write here the header</textarea><br /><br />
<textarea cols="30" rows="1" id="desc1">write here the paragraph</textarea>
<input type="button" value="show" onclick="doit()">
</div>
<script type="text/javascript">
function doit() {
var title = document.getElementById("title1").value;
var desc = document.getElementById("desc1").value;
document.write("<h1>"+title+"</h1>").style.color="blue";
document.write(desc);
}
</script>
</body>
</html>
document.writeis not a good idea useappendinstead