ie 7&;8不会使用jquery隐藏选项卡

ie 7&;8不会使用jquery隐藏选项卡,jquery,Jquery,我有一个简单的jquery选项卡,它在除IE7和IE8之外的所有浏览器中都能正常工作。我看不出有什么问题 $('#tabs > div').hide(); $('#tabs div:first').show(); $('#tabs ul li:first').addClass('active'); $('#tabs ul li a').click(function(){ $('#tabs ul li').removeClas

我有一个简单的jquery选项卡,它在除IE7和IE8之外的所有浏览器中都能正常工作。我看不出有什么问题

      $('#tabs > div').hide();
      $('#tabs div:first').show();
      $('#tabs ul li:first').addClass('active');

      $('#tabs ul li a').click(function(){
        $('#tabs ul li').removeClass('active');
        $(this).parent().addClass('active');
        var currentTab = $(this).attr('href');
        $('#tabs > div').hide();
        $(currentTab).fadeIn(400).show();
        return false;
      });
以下是选项卡:

        <div id="tabs">  

            <!--Menu-->          
            <ul class="grid12 first menu">
                <li class="grid3 first">
                    <a href="#tab-1">ABOUT US</a>
                </li>
                <li class="grid3">
                    <a href="#tab-2">FACILITIES</a>
                </li>
                <li class="grid3">
                    <a href="#tab-3">SPECIALS</a>
                </li>
                <li class="grid3">
                    <a href="#tab-4">CONTACT</a>
                </li>  
            </ul>

            <!--Content Area-->
            <div id="tab-1">
                <div id="about">
                    <div class="grid5 first"> <a href="http://www.treacyshotelwaterford.com"><img src="http://www.ingemit.com/res360/facebook/about.jpg" alt="Spirit Spa"></a></div>

                <div class="grid7">
                    <h1>
                        <em>Welcome to Treacys Hotel Waterford, Spa & Leisure Centre</em></h1>
                    <p>
                        <strong><span class="drop-caps">F</span>ormerly Days Hotel Waterford, Treacy's Hotel Spa & Leisure Centre is situated in the heart of Waterford City in Ireland's Sunny South-East, and is proud to be one of the finest hotels in Waterford.  The hotel is the perfect choice for your business, leisure and family breaks.  Guests can dine in Croker's Restaurant, enjoy a drink with friends in Timbertoes bar, relax in the swimming pool or Jacuzzi at Spirit Leisure Centre or be pampered at Spirit Beauty Spa.</strong>
                    </p>
                    <p>
                        The hotel is ideally located on the Quays in Waterford and is just a five minute walk from both the bus and train stations, and only 10km from Waterford Airport.  Treacys hotel is one of the finest hotels in Waterford city centre and is a popular location for visitors who love shopping, golf, surfing, or choose from our selection of great value packages, including pampering spa breaks and activity breaks.
                    </p>
                    <p>
                        Planning your wedding? See why we are one of the best wedding hotels in Waterford. Whatever the reason come and see us and you can be assured of a warm welcome and a great time.
                    </p>
                </div>
                </div><!--about end-->
            </div><!--tab1 end-->  

            <div id="tab-2">
                <div class="grid12 first">
                    Facilities
                </div>
            </div>

            <div id="tab-3">
                <div class="grid12 first">
                    Specials
                </div>
            </div>

            <div id="tab-4">
                <div class="grid4 first">
                  <h2>Contact Us</h2>
                    <p><strong>Address:</strong> <span class="lightgrey">1458 Sample Road, Greenvalley, 12</span><br>
                      <strong>Telephone:</strong> <span class="lightgrey">+123-1234-5678</span><br>
                      <strong>FAX:</strong> <span class="lightgrey">+458-4578</span><br>
                      <strong>Others:</strong> <span class="lightgrey">+301 - 0125 - 01258</span><br>
                  <strong>E-mail:</strong> <span class="lightgrey">mail@yoursitename.com</span></p>
                </div>

                <div class="grid8">
                    <p>Map image</p>
                </div>
            </div>
        </div>

欢迎光临沃特福德特雷西酒店水疗休闲中心 特雷西酒店水疗与休闲中心前身为沃特福德戴斯酒店,位于爱尔兰阳光明媚的东南部沃特福德市的中心,是沃特福德最好的酒店之一。酒店是您商务、休闲和家庭休息的最佳选择。客人可以在Croker's餐厅用餐,在Timbertoes酒吧与朋友一起畅饮,在Spirit休闲中心的游泳池或按摩浴缸中放松身心,或在Spirit Beauty Spa尽情享受。

酒店位于沃特福德的码头上,距离公共汽车站和火车站仅5分钟步行路程,距离沃特福德机场仅10公里。特雷西酒店是沃特福德市中心最好的酒店之一,是喜爱购物、高尔夫、冲浪或从我们精选的高价值套餐中进行选择(包括纵容水疗休息和活动休息)的游客的热门地点。

计划你的婚礼?看看为什么我们是沃特福德最好的婚礼酒店之一。无论出于什么原因来看我们,您都会受到热烈的欢迎,度过一段美好的时光。

设施 特色菜 联系我们 地址:12号格林瓦利样本路1458号
电话:+123-1234-5678
传真:+458-4578
其他:+301-0125-01258
电子邮件:mail@yoursitename.com

地图图像


IE在看到
href=“#something”
时所做的是在其前面附加URL:

例如,在本页上,如果您:

$('a').click(function(){
   alert(this.href);
});
它将发出警报
http://stackoverflow.com#something

您需要做的是利用
标记的另一部分进行定义。尝试按如下方式格式化标记:

            <li class="grid3">
                <a href="#tab-4" data-link="tab-4">CONTACT</a>
            </li>  

我们可以看看你的html吗?你的html是什么样子的?currentTab不包含URL吗?那么为什么$(currentTab).fadeIn(400).show()???我明白了,但请确保str_替换域名:)@ToniMichelCaubet,因此我的答案是^ ^为什么var currentTab=“#”+$(this.attr('data-link')??我是否应该将内容包装在标签页中,现在我不需要,但它在所有其他浏览器中都可以工作?Thanks@ToniMichelCaubet这是因为您应该使用可以通过jQuery访问的数据属性。@Neal所以您只需使用data-var1=“value”data-var2=“value”??
   var currentTab = "#"+$(this).data('link');