Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery创建的下拉列表未在ie8中显示_Javascript_Jquery_Drop Down Menu - Fatal编程技术网

Javascript jquery创建的下拉列表未在ie8中显示

Javascript jquery创建的下拉列表未在ie8中显示,javascript,jquery,drop-down-menu,Javascript,Jquery,Drop Down Menu,我有创建下拉列表的代码,但在IE8中,下拉列表的条目数正确,但文本为空。它们确实包含正确的值。我看不出少了什么 if(max_ch>0){ var newDiv = $('<div>Room '+(i+1)+' <select class="adu" name="data[Rate]['+r_id+']['+ro_id+'][adults][]"></select> adults. <select class="chi" name="dat

我有创建下拉列表的代码,但在IE8中,下拉列表的条目数正确,但文本为空。它们确实包含正确的值。我看不出少了什么

if(max_ch>0){
    var newDiv = $('<div>Room '+(i+1)+' <select class="adu" name="data[Rate]['+r_id+']['+ro_id+'][adults][]"></select> adults. <select class="chi" name="data[Rate]['+r_id+']['+ro_id+'][children][]"></select> children.</div>');
    newDiv.attr("id","occupants"+i).appendTo(showdiv+' .rooms_adults');

    var roomPrice = $('<input type="hidden" name="data[Rate]['+r_id+']['+ro_id+'][prices][]" value="'+room_bo+'" />');
    roomPrice.attr("id","roomprice"+i).appendTo(showdiv+' .rooms_adults');

    var num_opts = Number(max_ad)+1;
    for( ad=0; ad < num_opts; ad++){
        $(showdiv+' #occupants'+i+' select.adu').append(new Option(ad, ad));
    }
    var num_opts = Number(max_ch)+1;
    for( ch=0; ch < num_opts; ch++){
        $(showdiv+' #occupants'+i+' select.chi').append(new Option(ch, ch));                    
    }
    $(showdiv+' #occupants'+i+' select.adu').val('1');

} else {
if(最大值>0){
var newDiv=$('Room'+(i+1)+'madures.children.');
newDiv.attr(“id”、“居住者”+i).附录(showdiv+’房间和成人);
var roomPrice=$('');
roomPrice.attr(“id”,“roomPrice”+i).appendTo(showdiv+'.rooms\u成人”);
var num_opts=数量(最大值)+1;
对于(ad=0;ad
您可以使用

var num_opts = Number(max_ad) + 1,
    slc_adu = $(showdiv+' #occupants'+i+' select.adu');
for( ad=0; ad < num_opts; ad++){
    slc_adu.append("<option value=\"" + ad + "\">" + ad + "</option>");
}
var num_opts=Number(max_ad)+1,
slc#u adu=$(showdiv+“#占用者”+i+“select.adu”);
对于(ad=0;ad

var num_opts=Number(max_ad)+1,
slc_adu=$(showdiv+“#占用者”+i+“select.adu”),
期权=slc_adu.attr(“期权”);
对于(ad=0;ad

否则IE将不会显示选项的相关文本值。

Josh的答案对我有效::


是的,对不起,我应该提到。我看到的信息是IE不支持的,但无法找到替代方案
var num_opts = Number(max_ad) + 1,
    slc_adu = $(showdiv+' #occupants'+i+' select.adu'),
    options = slc_adu.attr("option");
for( ad=0; ad < num_opts; ad++){
    options[options.length] = new Option(ad, ad);
}
var o = new Option("option text", "value");
/// jquerify the DOM object 'o' so we can use the html method
$(o).html("option text");
$("#selectList").append(o);