前端知识学习

<html>
<head> <title>文字变换颜色 样式 </title>

</head>
<script>
function changeColor()
{
	var title = document.getElementById("title").value;
	var select = document.getElementById("selector").value;
	if(select=="two")
	{
		document.getElementById("title").style.color="green"; 
	}
	else document.getElementById("title").style.color="red";
}

function changeStyle()
{
	var title = document.getElementById("title").value;
	var select = document.getElementById("selector2").value;
	if(select=="two")
	{
		document.getElementById("title").style.fontFamily="Times New Roman"; 
	}
    else
        document.getElementById("title").style.fontFamily="楷体";
}

</script>
<body>
	<form name="form1">
	<input type="text" name="title" id="title" value="黑色头发" style="font-family:Helvetica;">
	<select name="selector" id="selector" onchange="changeColor()">
		<option value="one">红色 </option>
		<option value="two">绿色 </option>
	</select>
	<select name="selector2" id="selector2" onchange="changeStyle()">
		<option value="one">宋体 </option>
		<option value="two">楷体 </option>
	</select>
	</form>
</body>
</html>