2011-11-07 14 views
0

我有一个简单的jquery选项卡,它可以在除了ie 7 &之外的所有浏览器中正常工作。8.无法看到它的问题。即7&8不会隐藏与jquery的标签

 $('#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">[email protected]</span></p> 
       </div> 

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

我们可以在你的HTML看看吗? – Samich

+0

你的html是什么样的? – Neal

+0

Does not currentTab包含一个URL?那么为什么$(currentTab).fadeIn(400).show(); ??? –

回答

1

时,看到href="#something"是它追加之前的URL IE能做什么:此页面上

因此,举例来说,如果你做的事:

$('a').click(function(){ 
    alert(this.href); 
}); 

它会提醒http://stackoverflow.com#something

你需要做的是利用<a>标签的另一部分来做你的定义。尝试格式化标签,像这样:

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

然后在你的代码,你可以这样做:

var currentTab = "#"+$(this).data('link');