The hide() and on() methods are not compatible with Internet Explorer (IE)

My code is working fine on Google Chrome, but for some reason it's not functioning properly on Internet Explorer (IE). I'm using IE11 and really need this to work on all browsers.

Please help me figure out what's going wrong here.

$('.on').hide();
$('.off, .on').on('click',
function() {
$('.off, .on').toggle()
});
.on {
    width: 100%;
    position: relative;
}

.on:before {
    content:'';
    position: absolute;
    border-bottom: 2px solid #5092e3;
    width: 100%;
    transform: translateY(-50%);
    z-index:0;
    top:50%;
}

.off {
    width: 100%;
    position: relative;

}

.off:before {
    content:'';
    position: absolute;
    border-bottom: 2px dashed #666666;;
    width: 100%;
    transform: translateY(-50%);
    z-index:0;
    top:50%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div class="off">                        
   &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
</div>
<div class="on">
  &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
</div>

Answer №1

In my opinion, it is necessary to include the !DOCTYPE declaration for compatibility with IE8.

-PolyglotPete

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 for selecting the "save as" option while downloading a file?

Imagine a scenario where you click on a link like this: <a href="1.txt">Download</a> After clicking the link, a save as window will appear. Is it feasible to utilize JavaScript in order to simulate button clicks within that window? Alternativ ...

How can I populate an array with objects from a different array in Javascript using AngularJS?

Currently, I am facing a challenge in my angularjs application. I have a huge array containing the cast of a movie, which includes directors, producers, and film crew members. My goal is to create a new array specifically for the director(s). I am unsure ...

Automate web page interactions using Python Selenium to duplicate a class

Is there a method to duplicate a class? view image description here Upon examining the data-sitekey, I aim to replicate everything following it, namely 6Ld_LMAUAAAAAOIqLSy5XY9-DUKLkAgiDpqtTJ9b. Is this feasible? ...

"Material-UI enhanced React date picker for a modern and user-friendly

Currently, I am utilizing the Date picker feature from Material UI. The code snippet responsible for implementing it is as follows: import { DatePicker } from 'redux-form-material-ui'; <Field name="birthDate" ...

Is it possible to dynamically add an id or class to an element using document.createElement in JavaScript?

As a beginner in the world of JavaScript, I understand that the code structure I have used here may not be ideal for real-world applications. However, I am using it to practice my understanding of for loops and fetching JSON data. My main query is whether ...

Leveraging the outcome of JSON within PHP variables

I would like to completely rewrite my question. My goal is to update the display of five variables without having to reload the entire page. I have a PHP file called check_conf_update.php which executes a query, retrieves data, and converts it into JSON ...

Organize the table data based on time

My website specializes in offering cell phone rental services. Users can visit the site to view the available devices that we have. I designed the display of these devices using a table format and components from "@mui/material". One of the columns in thi ...

Issues persist with AJAX call to servlet

Recently, I encountered an issue with my servlet when attempting to insert form input fields into the database. The servlet was working fine when utilizing the following code: <form action="CreateUserServlet"> However, upon implementing some form v ...

Mongoose failing to retrieve data from MongoDB

In my code, I am utilizing data from the database: Assignment and the Collection: todolist. The code is designed to interact with MongoDB in order to add, delete, or list the JSON in the collection. To properly explain the issue, I will first showcase the ...

Once more baffled by the nested boxes, this iteration adorned in vibrant hues and trimmed with a striking border

In a previous inquiry, I sought advice on centering one box within another. However, my attempts this time around have led to some peculiar results. I experimented with two different code variations- one involving a background color and the other utilizing ...

Steer clear of dividing words

I am attempting to showcase sentences letter by letter with a fade in/fade out effect. However, I am facing an issue where words break in the middle. How can this word breaking be prevented? var quotes = document.getElementsByClassName('quote' ...

Using ng-repeat with deeply nested objects

I am facing an issue with rendering an object that contains comments along with replies objects that have nested replies objects. I attempted to use a solution from here, but it resulted in my replies object being undefined. For example, I tried the follow ...

Optimizing CSS usage within Django: top recommendations

Throughout a 6-month-long project, I have continuously added new URLs. However, I am now encountering an issue when using the extend 'base.html' function on other pages where the CSS overlaps and creates confusion. My question is: What are the b ...

By default, use jQuery to load the content of a div

Upon page load, I am looking to display the content within #destiny2. This section includes text and images, as well as additional content for three categories. Initially, the first category should be shown without requiring a click. Subsequently, clicking ...

Issue with refreshing Angular2 page causing it to not load

Encountering an issue here. When clicking on the anchor tag in my index <a href="/month/1">Month</a> the app fails to load, but when clicking on the anchor tag in my component <a routerLink="/month/1"> Month</a> the app success ...

WebAPI provides a similar functionality to an array in JavaScript through the use of IQueryable

I have a WebAPI method that returns an IQueryable of a 'complex' object in the following format: [Route("api/INV_API/deptSelect")] public IQueryable<DEPTNAME_DESCR> GetDistinctDeptSelect([FromUri] string q) { if (q != null) ...

Issue with jquery in Bootstrap 4

I'm encountering an error even after adding the script tags for jquery, tether, and bootstrap. The error persists despite following Bootstrap's starter template on their website while attempting to integrate it into an electron app. Here is the ...

Set the camera to view the world from a y-coordinate of 0 and descend

How can I make the top of the render area in Three.js point to y=0 in the world? I also want the camera to look straight (lookAt) These are my current values: camera = PerspectiveCamera camera.position.z = 1895.8448868133867 camera.fov = 20 screen.width ...

Utilizing Core-TransitionEnd in Polymer: A Beginner's Guide

After a ripple animation on an item has executed, I would like to run a function. Currently, I am using the following code: <post-card id="card1"> <img width="70" height="70" src="../images/start.png"> <h2>P ...

Personalizing the TabMenu or TabView Components in Angular with PrimeNg

Description: Currently tackling a project that involves recreating a widget similar to TabMenu/TabView in PrimeNg. Struggling with implementing different routerlinks on each button and customizing it to be more dynamic or resemble the provided image. Des ...