<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>
效果圖:
黑色頭發:http://heisetoufa.iteye.com/
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061
微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元

