日期:2014-05-16  浏览次数:20413 次

Javascript测试题 大家看看呀
1.如何获取表单 <select> 域的选择部分的文本?


2.在JavaScript中定时调用函数   foo()   如何写?


3.var   a   =   10;   var   b   =   20;   var   c   =   10;   alert(a   =   b);   alert(a   ==   b);   alert(a   ==   c);结果是?


------解决方案--------------------
1
<html>
<script>
function show(){
var select=document.getElementById( "select ");
var text=getText(select,0);
alert(text);
}
function getText(select,index){
if(select[index].value==select.value){
return select[index].innerHTML;
}else{
return getText(select,index+1);
}
}
</script>
<body>
<select id= "select ">
<option value= "a "> 中国 </option>
<option value= "b "> 美国 </option>
<option value= "c "> 英国 </option>
</select>
<input type= "button " value= "显示 " onclick= "show() "/>
</body>
</html>

2
setInterval( "foo() ",1000)

3
20,true,false