select动态选中问题
已知select 中有和1项和name3相同的值得
var tr=document.elementFromPoint(event.x,event.y).parentNode.parentNode;
var name3= tr.childNodes[3].innerText ;
var SelectSF=document.getElementById("Select_SF");
for(var i=0;i<SelectSF.options.length;i++)
{
if(SelectSF.options[i].value== name3)
{
SelectS[i].selected=true;
alert("ok");
break;
}
}
请问为什么这样不行,判断到if处就跳出,
还有我将这样测试也不行
var name3= "aaa" ; //SelectSF.options[2].value我指定了一个值也是"aaa"
var SelectSF=document.getElementById("Select_SF");
for(var i=0;i<SelectSF.options.length;i++)
{
if(SelectSF.options[2].innerText== name3)
{
SelectS[2].selected=true;
alert("ok");
break;
}
}
象这样测试也不行,不知道问题出那了,请高手看看