2011-05-06 66 views
0

我的谷歌技能正在让我失望。 我在IE 7.0中遇到以下问题(在FF 4.0中工作& Chrome)IE 7.0选择框重叠按钮

我最初有一个空的选择框。当我使用Jquery填充它的值时,选择框在按钮上重叠。

我假设有一个CSS的黑客攻击,但我没有得到正确的搜索结果。

我的代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title></title> 
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"> 
    </script> 
</head> 
<body> 
    <div> 
     <select id="missionList" name="missionList"> 
      <option></option> 
      <option value="1">1</option> 
      <option value="2">2</option> 
      <option value="4">4</option> 
      <option value="5">5</option> 
     </select> 
     <select name="peopleList" id="slPeopleFoundList" size="5" multiple="multiple"> 
     </select> 
     <input type="submit" id="Remove" value="Remove" disabled="disabled" /> 
    </div> 
</body> 
</html> 
<script type="text/javascript"> 

    $(function() { 

     $("#missionList").change(function() { 
      SetupUpMissionList(); 
     }); 

     function SetupUpMissionList() { 
      var select = $("#slPeopleFoundList"); 

      appendOption("he asdfasdfasdf asdf asdf asdfllo", "hello", select); 
     } 

     function appendOption(text, value, select) { 
      $(select). 
        append($("<option></option>"). 
        attr("value", value). 
        text(text)); 
     } 

    }); 

</script> 
+0

我似乎无法复制您的问题。 http://jsfiddle.net/dj92U/1/ – anothershrubery 2011-05-06 12:41:13

+0

嘿Shrubery,在IE 7.0中打开你的链接,你应该看到这个问题。顺便提一下,我不得不随身携带.. – Lareau 2011-05-06 12:45:11

+0

对不起,误解了这个问题,我现在看到了。 – anothershrubery 2011-05-06 12:51:32

回答

1

笨,笨IE以下位。我试图在代码中加入.hide()/。show(),它为select元素添加了选项,它的工作方式如下所示:

select.hide(); 
appendOption("he asdfasdfasdf asdf asdf asdfllo", "hello", select); 
select.show(); 
+0

谢谢,这是一个很好的工作 – Lareau 2011-05-06 12:43:18

+0

这也似乎工作后添加到选择列表项目:'/ *如果IE版本<= 7然后*/$(选择).css({宽度:“汽车”} )' - [在此处查看演示](http://jsfiddle.net/kkSPa/11/) – 2011-05-06 12:46:31

+1

将'width:auto'添加到css可能是更好的解决方案2. – anothershrubery 2011-05-06 12:53:13