<!doctype html>
<html><head><meta charset=" utf-8">
<title>
脚本学堂 - www.jb200.com</title>
<script type="text/
javascript">
function getDefaultSelectedOption(selectId) {
var dom,selectId=selectId.replace(/^#/,''),opts;
try{
var osel=document.getElementById(selectId);
opts=osel.getElementsByTagName('option');
for(var i in opts){
if(opts[i].defaultSelected){
dom=opts[i];
break;
}
}
}
catch(e){}
return dom;
}
window.onload=function(){
document.getElementById('btn').onclick=function(){
alert((getDefaultSelectedOption('sel')).value);
}
}
</script>
</head>
<body>
<select id="sel">
<option value="1">脚本学堂一</option>
<option selected>脚本学堂二</option>
<option value="3">脚本学堂三</option>
</select>
<button id="btn">查看效果</button>
</body>
</html>