Keith Power
Keith Power

Reputation: 14141

ie 7 & 8 will not hide tabs with jquery

I have a simple jquery tab, which works fine in all browser except ie 7 & 8. Cant see an issue with it.

      $('#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;
      });

Here is the tabs:

        <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>

Upvotes: 0

Views: 168

Answers (1)

Naftali
Naftali

Reputation: 146310

What IE does when it sees href="#something" is that it appends the URL before it:

So for example on this page if you did:

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

It would alert http://stackoverflow.com#something

What you need to do is utilize another part of the <a> tag to do your defining. Try formatting the tag like so:

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

Then in your code you can do:

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

Upvotes: 1

Related Questions