jquery - Javascript .find() not working under all the IE browser -
i have js code converts html dropdown bootstrap dropdown:
jquery(function($){ $('#primary').each(function(i, e) { if (!($(e).data('convert') == 'no')) { $(e).hide().wrap('<div style="display:inline-block;" class="btn-group" id="select-group-' + + '" />'); var select = $('#select-group-' + i); var current = ($(e).val()) ? $(e).val(): 'category'; select.html('<input type="hidden" value="' + $(e).val() + '" name="' + $(e).attr('name') + '" id="' + $(e).attr('id') + '" class="' + $(e).attr('class') + '" /><a data-toggle="dropdown" style="border-radius:4px 0px 0px 4px; margin-right:0px;" class="btn" href="javascript:;">' + current + '</a><a class="btn dropdown-toggle" data-toggle="dropdown" href="javascript:;"><span class="caret"></span></a><ul style="max-height:300px; overflow-y:scroll; overflow: -moz-scrollbars-vertical;" class="dropdown-menu"></ul>'); $(e).find('option').each(function(o,q) { if($(q).attr('value') > 0) { if($(q).attr('value') == 30 || $(q).attr('value') == 17 || $(q).attr('value') == 185 || $(q).attr('value') == 196 || $(q).attr('value') == 197 ) { select.find('.dropdown-menu').append('<li style="background-color:#fffacd;"><a href="javascript:;" data-value="' + $(q).attr('value') + '">' + $(q).text() + '</a></li>'); } else { select.find('.dropdown-menu').append('<li><a href="javascript:;" data-value="' + $(q).attr('value') + '">' + $(q).text() + '</a></li>'); } } if ($(q).attr('selected')) select.find('.dropdown-menu li:eq(' + o + ')').click(); }); select.find('.dropdown-menu a').click(function() { select.find('input[type=hidden]').val($(this).data('value')).change(); select.find('.btn:eq(0)').text($(this).text()); }); } }); });
i checked ie console, there no error showing @ all...
it's showing fine in webkit browsers safari/chrome not ie. in ie (ie 10), dropdown empty this: (empty in html)
which in safari, it's this:
updates:
after more debugging, problem here...looks line $(e).find('option').each(function(o,q) {
not working in ie since codes inside not operating. the problem .find()
. changed .children('option')
or .children()
, not working in ie. i'm using jquery 1.7.2.
$(e).find('option').each(function(o,q) { ... }
inspect dropdown ul
element , check if lis there, seems css problem, common on ie.
try giving ul ant elements float: left
; , width
.
Comments
Post a Comment