The tab navigation feature is experiencing issues in Internet Explorer versions 7 and 8

I have successfully implemented a tab menu that functions well in Chrome and IE 9,10. However, it does not seem to work in IE 7 or 8. I am at a loss regarding what changes need to be made to my code.

Could anyone provide assistance?

Link to Code Example

<ul class="hr_tab menu1">  
  <li class="tab1 on" data-tab="tab-1" data-trigger-class="menu1">  
     <a href="#">tab1</a>
  </li>
  <li class="tab2" data-tab="tab-2" data-trigger-class="menu2">
     <a href="#">tab2</a>
  </li>
  <li class="tab3" data-tab="tab-3" data-trigger-class="menu3">
     <a href="#">tab3</a>
  </li>
</ul>


<div id="tab-1" class="tab_content on">111</div>
<div id="tab-2" class="tab_content">22</div>
<div id="tab-3" class="tab_content">33</div>

.tab_content { display:none; }
.tab_content.on { display:inherit;}


$(document).ready(function(){
  $('ul.hr_tab li').click(function(e){
    var tab_id = $(this).attr('data-tab');
    $('ul.hr_tab li').removeClass('on');
    $('.tab_content').removeClass('on');
    $(this).addClass('on');
    $("#"+tab_id).addClass('on');
    $('.hr_tab').removeClass('menu1 menu2 menu3');
    $('.hr_tab').addClass($(this).attr('data-trigger-class'));
    e.preventDefault();
  });
})

Answer №1

If you have not already added it, consider inserting the following code in the HTML head section:

<meta http-equiv="X-UA-Compatible" content="IE=edge">

This will prompt IE to display as if it is the most recent version (Learn more about what <meta http-equiv="X-UA-Compatible" content="IE=edge"> does)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the method to include additional value in the User-Agent header for a .ajax request?

My goal is to develop a Chrome plugin that retrieves information from multiple pages, some of which are behind a load balancer requiring a specific user agent code for proper routing. I am currently using an .ajax() call and have experimented with differe ...

switch from material ui lists on/off

Trying to learn React through coding, I've encountered an issue with displaying the 'StarBorder' icon next to folders when clicked. Currently, clicking on any folder displays the 'StarBorder' icon for all folders. Any tips on how t ...

Tips on ensuring Angular calls you back once the view is ready

My issue arises when I update a dropdown list on one of my pages and need to trigger a refresh method on this dropdown upon updating the items. Unfortunately, I am unsure how to capture an event for this specific scenario. It seems like enlisting Angular ...

What is the best way to implement this header style with code?

I came across this design from a potential client recently, even though we didn't end up working together. I thought it would be a good exercise to try coding the design for practice purposes. Just to clarify, this is not my original design and I have ...

Is it possible to use React and Material-UI to make a paper element extend to full width beyond the boundaries of a Container?

Assuming I have the following code snippet: <Container maxWidth='lg'> <Grid container spacing={3}> <Grid item xs={12} md={6} > <Image src="/img/undraw_programming_2svr.png" color='transparent' ...

What is the best way to ensure an image is responsive in CSS and aligns perfectly in height with its neighboring text?

There is an image within the <img> tag and some text inside the <p> tag, both enclosed in a <div>. Although the image is responsive and resizes proportionally when the browser window changes size, there is an issue where as the text wrap ...

Using JavaScript regular expressions for email validation criteria

Hey there, I am struggling with Regular Expressions, especially when it comes to client side validation for a specific field. Can you please help me come up with a Regular Expression that would verify if an email address is valid based on these criteria: ...

Unable to convert data to a JSON string

I've created a tool for building dynamic tables: <div class="container"> <div class="row"> <div class="col"> <hr> <h3>Add your data</h3> <button id="addTd" type="button" class="btn btn-pr ...

What is causing my server to mysteriously alter the style of index.html?

After setting up a node, express, react app, I realized that when express serves static content like my CSS file, the source of the index.html shows an additional style tag in the head section: <style type="text/css">* {}</style> I confirme ...

Removing CSS from an HTML document using Gulp

My Web App is built using Angular and I encountered an issue with Gulp. Every time I add a new custom CSS line to my HTML file and run Gulp, it automatically removes that line from the file. <!--MATERILIZE CORE CSS--> <link h ...

What is the best way to conceal a dropdown menu when the page first loads?

I have a dropdown menu that is displaying like this: <ul> <li class="dropdown open"> <a aria-expanded="true" href="#" class="dropdown-toggle waves-effect waves-button waves-classic" data-toggle="dropdown"> <spa ...

Ensure the first column is fixed and all other columns have the same height

I have encountered an issue where the first column of my table has varying heights compared to the other columns, resulting in inconsistent row heights. Below is the code I am using: <div class="outer"> <div class="inner"> <table> ...

Make sure the division remains fixed even when the window is resized

Having a fixed position and bottom set to 0, I want my div to display at the bottom of the window. The issue arises when the window is resized, causing the div to move up and into other elements. For instance, when opening the console box in Chrome, the f ...

Unexpected issue encountered while working with json, ajax, and jQuery

Here's the code snippet that I'm working with: $.ajax({type: 'get', mode: 'abort', dataType: 'json', url: 'http://localhost/1.php', data: {}, success: function(res){ alert(res); }, time ...

Using the Jquery accordion function within google maps is limited to running only one time

After successfully creating a google maps page with markers generated from XML, I encountered an issue. The plan was to display event information in a div when a marker is clicked, along with attaching an accordion to the events data. Although the first cl ...

Incorporate the combination of jQuery and AJAX within a PHP loop that is enclosed within an AJAX function

Currently, I am facing an issue with my while loop that fetches and displays status updates. My goal is to include a "REPOST" link within the loop that, when clicked, will append below the respective status update and pass the ID to an external .php file u ...

Adjust iFrame to allow scrolling dynamically

I am currently facing a challenge with creating a non-scrollable iframe element using JavaScript. The function I need to call is within an iframe, and while it works on Firefox and Chrome, I also need it to work on Internet Explorer. My solution involves ...

Having trouble with the functionality of a simple jQuery toggle menu on mobile?

I am experiencing an issue with a simple toggle menu that utilizes jQuery's on: tap feature, but it is not functioning as expected: <nav id="mobile-nav"> <ul> <li>Item 1</li> <li>Item 2</li> ...

Conceal elements of a rectangular shape using CSS

https://i.stack.imgur.com/ebaeI.jpg I need help hiding the second rectangular shape on my website. I want the width to be 100% and responsive, but whenever I use position: absolute; with right:-10%, it's not working as expected. Even trying body { ma ...

List of prices with a dotted line separating the price and product, adjusting its width based on

I am attempting to create a price list with a dotted underline between the price and product that adjusts dynamically in width. Here is my code snippet: https://jsfiddle.net/romariokbn/2gm27rv6/ <ul class="how-can-i-do"> <li> <span ...