jQuery无法在IE9中隐藏选项

jQuery not working in IE9 for hiding options

本文关键字:隐藏 选项 IE9 jQuery      更新时间:2023-09-26

对于此页面:http://rmetro.uscav.com/az/fire/duty-shirts/09820.html

它隐藏基于URL的选项。除了IE9的糟糕,你知道罪魁祸首是什么吗?

<script>
$j(window).load(function(){
    var url = window.location.href;
    url =  url.split('/');
var word = url['3'].replace(/-/g,' ');
   var select =  $j('#product-options-wrapper').find('div.option label:contains("Patch Type")').parents('div.option').find('select');
    var totalOption = select.find('option').length;
    var count = 0;
    select.find('option').each(function(i){
        if($j(this).text().toLowerCase().indexOf(word) == -1){
            $j(this).wrap('<span>').hide();
            count++;
        }
        if(count === totalOption){
            select.find('option').each(function(){
                if($j(this).text().toLowerCase().indexOf('generic') >= 0){
                    if($j(this).parent().is('span')){
                        $j(this).unwrap().show();
                    }
                }
            });   
        }
        if(i+1 === totalOption){
            select.find('option').eq(1).unwrap().show();
        }
      });
      if(word.indexOf('ca') == -1){
        $j('#product-options-wrapper').find('div.option label:contains("San Diego Badge Type")').parents('div.option').hide();
      }
 });
</script>

您的页面上有一个错误:

TypeError: $j(...).cycle is not a function

也许浏览器处理它的方式不同。我建议你先解决这个问题,然后再试一次。