黑马程序员技术交流社区
标题:
select选择后为什么没反应啊,哪里写错了么?
[打印本页]
作者:
hhmm665544
时间:
2014-4-15 17:38
标题:
select选择后为什么没反应啊,哪里写错了么?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function seldemo()
{
var selNode = document.getElementById("selid");
var name = selNode.selectedIndex.value;
var divNode1 = document.getElementById("div1");
var divNode2 = document.getElementById("div2");
divNode1.style.textTransform = name;
divNode2.innerHTML = "text-transform : "+name+";";
}
</script>
<style>
#div1{
background-color:#FC0;
height:100px;
width:300px;
}
#div2{
background-color:#666;
width:300px;
}
</style>
</head>
<body>
<div id="div1">
Good Good Study, Day Day up
</div>
<p></p>
<select id="selid" onchange="seldemo()">
<option value="none">---none-----</option>
<option value="uppercase">大写</option>
<option value="lowercase">小写</option>
</select>
</body>
<p></p>
<div id="div2">
text-transform : none;
</div>
</html>
复制代码
作者:
你为谁归来
时间:
2014-4-15 20:23
把var name = selNode.selectedIndex.value; 改成
var name =selNode.options[selNode.selectedIndex].value;
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2