日期:2014-05-16 浏览次数:20280 次
<script>
function foo(obj){
obj.selectedIndex=0;
}
</script>
<form action='f.php' method='post'>
<select name='key' id='key' onchange='foo(this)'>
<option value=0>All</option>
<option value=1>aa</option>
<option value=2>bb</option>
<option value=3>cc</option>
</select>
<input type='submit'>
</form>
<select name='key' id='key' disabled="disabled">
<option value=0>All</option>
<option value=1>aa</option>
<option value="2" selected="selected">bb</option>
<option value=3>cc</option>
</select>
<script type="text/javascript">
alert(document.getElementById('key').value)
</script>
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
function getValue(){
alert("第1个select的值:"+document.getElementById('select1').value);
alert("第2个select的值:"+document.getElementById('select2').value);
}
</script>
</head>
<body>
<div>
<div style="border:solid 1px green;" >
第1种:按原意,不过客户可能还是会有点误会的(能够动,为什么修改不了?)<br />
<select id="select1" onfocus="this.defaultIndex=this.selectedIndex;" onchange="this.selectedIndex=this.defaultIndex;">
<option value="1">test1</option>
<option value="2">test2</option>
<option value="3" selected="selected">test3</option>
<option value="4">test4</option>
<option value="5">test5</option>
</select>
</div>
<div style="border:solid 1px red;" >
第2种:在加载完span和select时,将select2的值给span<br />
<span id="spanSelect2" ></span>