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

列表框判断
我在表单上添加了6个列表框,每个列框我都没有给id,我用了这样一条语句去得到列表框的数量var   getselect   =   document.getElementsByTagName( "select ");
getselect的长度就是6了,但是在浏缆表单时我只判断第1,3,5个列表框,随意点击这三个列表框中其中的一个,我要怎样判断这三个列表框中其中的某一个列表框是否获得焦点呢?请高人帮忙解决一下,谢谢!


------解决方案--------------------
Easy

注:问题解决请及时结贴!点击问题列表右侧的管理链接!

L@_@K

<body>
<select>
<option value= "0 "> select01 </option>
<option value= "1 "> calico </option>
<option value= "2 "> tortie </option>
<option value= "3 "> siamese </option>
</select>
<select>
<option value= "0 "> select02 </option>
<option value= "1 "> calico2 </option>
<option value= "2 "> tortie2 </option>
<option value= "3 "> siamese2 </option>
</select>
<select>
<option value= "0 "> select03 </option>
<option value= "1 "> calico3 </option>
<option value= "2 "> tortie3 </option>
<option value= "3 "> siamese3 </option>
</select>
<select>
<option value= "0 "> select04 </option>
<option value= "1 "> calico4 </option>
<option value= "2 "> tortie4 </option>
<option value= "3 "> siamese4 </option>
</select>
<select>
<option value= "0 "> select05 </option>
<option value= "1 "> calico5 </option>
<option value= "2 "> tortie5 </option>
<option value= "3 "> siamese5 </option>
</select>
<select>
<option value= "0 "> select06 </option>
<option value= "1 "> calico6 </option>
<option value= "2 "> tortie6 </option>
<option value= "3 "> siamese6 </option>
</select>
<script type= "text/javascript ">
<!--
var colselect = document.getElementsByTagName( "select ");
for (var i=0; i <colselect.length; i+=2)
{
colselect[i].onfocus = showMe;
}

function showMe()
{
alert(this.options[0].text + " say: Don 't touch me! ");
// To do what you want.
}

//-->
</script>
</body>