jQuery/JavaScript选项卡不适用于IE9

jQuery/JavaScript选项卡不适用于IE9,javascript,jquery,tabs,prototypejs,Javascript,Jquery,Tabs,Prototypejs,除了IE 9,我的这些标签在任何浏览器中都能完美工作。我已经尝试解决这个问题好几天了,我想我快疯了 <div class="product-collateral"> <div class="tab"><h3 class="product_tabs_additional">Additional Information</h3></div> <div class="product-tabs-cont

除了IE 9,我的这些标签在任何浏览器中都能完美工作。我已经尝试解决这个问题好几天了,我想我快疯了

<div class="product-collateral">

         <div class="tab"><h3 class="product_tabs_additional">Additional Information</h3></div>
        <div class="product-tabs-content" id="product_tabs_additional_contents">
            Additional Information Content
        </div>

        <div class="tab"><h3 class="product_tabs_agenda">Agenda</h3></div>
        <div class="product-tabs-content" id="product_tabs_agenda_contents">
            Agenda Content
        </div>


        <div class="tab"><h3 class="product_tabs_terms">Terms and Conditions</h3></div>
        <div class="product-tabs-content" id="product_tabs_terms_contents">
            Terms and Conditions Content
        </div>


        <div class="tab"><h3 class="product_tabs_locations">Locations</h3></div>
        <div class="product-tabs-content" id="product_tabs_locations_contents">
            Locations Content
    </div></div>

补充资料
附加信息内容
议程
议程内容
条款和条件
条款和条件内容
位置
位置内容

$jQ=jQuery.noConflict();
$jQ('.product-collateral.tab h3').wrapAll('
    ).wrap('
  • ); $jQ('.product-parallery.product-tabs-li')。每个(函数(索引){ $jQ(this.attr('id'),$jQ(this.find('h3').attr('class')); 如果(索引==0){ $jQ(this.addClass('active'); } }); // ​
    我知道其中一行
    $$(选择器+h3')。每行(this.initTab.bind(this))有一个2x$,但没有它脚本将停止工作

    我根本不是JavaScript专家,因此我的问题就来了。对我来说最奇怪的是,这个脚本在IE7和IE8模式下运行,没有任何问题。只有IE9正在崩溃

    非常感谢您的帮助

    先谢谢你


    Dom

    查看您的页面,您使用的是2008年发布的旧版本prototype(1.6.0.3),即IE9之前的版本。在这个版本中,当您运行以下行时:
    ul。选择('li','ol')
    它将返回空列表,而不是您期望的4元素列表

    快速修复:尝试将行更改为:
    ul.select('li')
    ,这将选择此处需要的所有元素


    更好的修复方法:升级到的最新版本。

    请检查您的代码,并避免在页面上声明多个版本的jQuery。我认为这是jQuery冲突的问题。

    您是否也包含了库?该库使用
    $
    表示选择与给定查询字符串匹配的元素,这可能是您所引用的行的情况。您得到的错误是什么?谢谢标记。我试着添加这个,但仍然没有结果。我可以给你看看网站吗。非常感谢你的帮助。
    <script type = "text/javascript" > $jQ = jQuery.noConflict();
    $jQ('.product-collateral .tab h3').wrapAll('<ul class="product-tabs"></ul>').wrap('<li></li>');
    $jQ('.product-collateral .product-tabs li').each(function(index) {
        $jQ(this).attr('id', $jQ(this).find('h3').attr('class'));
        if (index === 0) {
            $jQ(this).addClass('active');
        }
    });
    //<![CDATA[
    Varien.Tabs = Class.create();
    Varien.Tabs.prototype = {
        initialize: function(selector) {
            var self = this;
            $$(selector + ' h3').each(this.initTab.bind(this));
        },
    
        initTab: function(el) {
            el.href = 'javascript:void(0)';
            if ($(el.parentNode).hasClassName('active')) {
                this.showContent(el);
            }
            el.observe('click', this.showContent.bind(this, el));
        },
    
        showContent: function(a) {
            var li = $(a.parentNode),
                ul = $(li.parentNode);
            ul.select('li', 'ol').each(function(el) {
                var contents = $(el.id + '_contents');
                if (el == li) {
                    el.addClassName('active');
                    contents.show();
                } else {
                    el.removeClassName('active');
                    contents.hide();
                }
            });
        }
    }
    new Varien.Tabs('.product-tabs');
    //]]>
    < /script>​