The toggleClass() function appears to be functioning properly in all browsers except for IE11

Check out my code snippet:

Using Jquery:

$("#welcome-done").on("click", function(){
    $(".welcome-box").toggleClass("hide");
})

In the CSS:

.hide {
    display: none;
}

.welcome-box {
    padding-left: 0;
    background-color: white;
    border-radius: 12px;
    border-top: 6px solid;
    border-top-color: #0072FF;
    box-shadow: 0px 0px 300px 200px rgba(0,0,0,0.3);
    position: absolute;
    left: 50%;
    top: 170px;
    transform: translate(-50%);
    height: 500px;
    width: 50%;
    max-width: 700px;
    z-index: 700;
}

The code works in major browsers like Firefox, Chrome, and Safari, but fails to work in IE11. Any ideas on how to fix this compatibility issue?

UPDATE:

Even with the following code snippet adjustment, the functionality is still broken in IE11 (while it works perfectly fine in other browsers):

$("#welcome-done").on("click", function(){
    $(".welcome-box").toggle();
})

LATEST UPDATE:

An error message is now showing up exclusively in the console of IE11:

SCRIPT1003: Expected ':'
File: app.js, Line: 10397, Column: 10

Answer №1

If you have a specific element that you want to show or hide with a simple click, you can utilize the toggle method in this way:

$("#welcome-done").on("click", function(){
    $(".welcome-box").toggle();
});

For more information on the toggle method, you can visit the documentation here.

Answer №2

It appears that there is a glitch in internet explorer when using toggleClass, which is quite unfortunate.

Fortunately, there is a workaround that can be implemented. For instance, you can include the following CSS code:

#welcome-done{
    Padding-left: 0;
}

#welcome-done .hide{
    Display: none;
    Padding-left: 1px;
}

The utilization of padding is done to trigger a redraw, which has successfully resolved similar issues for me in the past.

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

Is it just me or does my wrapper always hover above the bottom of the screen?

I have been working on coding a simple layout that I created last year. Most of the work is done, but I ran into an issue where the 'wrapper' div doesn't extend to the bottom of the page as expected. It almost looks like it has the "position ...

Troubleshooting: jQuery and jQuery UI slider event not triggering on jump/click action

I am working on a jQuery slider that is designed to cycle through a series of divs. I have noticed that when I drag the slider and release it, the handleSlider() function is triggered. However, if I simply click on a random point within the slider, the f ...

The function .get() is expecting callback functions, however it received an undefined object at route.(anonymous function) as get[]

Hey everyone, I've encountered an error in my server.js file and being a beginner I'm struggling to find a solution. I've searched through numerous answers on Stack Overflow but haven't been able to resolve it. Can someone please help m ...

"Use jQuery to toggle the slide effect for the first element of a

Below is the HTML code snippet: <div class="row header collapse"> Content 1 <i class="fas fa-chevron-circle-up" ></i> </div> <div class="instructions-container"> <div></di ...

Executing Java Script on several identical elements

Currently, I am facing an issue with my JavaScript function that is supposed to toggle the display of titles within elements. The function works perfectly fine on the first element, but it does not work on the other elements. Here is the code snippet: ...

Save user preferences using jQuery

My ad system code is as follows: function toggleAds() { if ($('.toggle-ads').html() == 'show ads') { $('.toggle-ads').html("show ads"); $('.ads').hide(); } else { $(&apos ...

Dynamic carousel - integrate seamlessly with AJAX requests

I've implemented the Liquid Slider on my website. There are numerous project pages on my site and I would like to utilize this slider with ajax to load individual HTML content in each slide. However, I'm unsure of where to begin with this proces ...

Clicking on the overlay does not close the bootstrap collapsed toggle

I'm currently facing an issue where I need to add a listener that closes the menu when clicked away. The code snippet below shows my attempt at solving this problem: $("body").click(function(e){ var $box1 = $('.navbar-toggle'); var $b ...

Troubleshooting Problem with Google Maps CSS

I'm in the process of constructing a website utilizing Foundation and have integrated Google Maps to showcase some markers on it. However, I've noticed that the map control elements in the top left corner (zoom in and zoom out) have disappeared, ...

modifying the appearance of the parent container of an input element

I'm trying to change the style of a parent element when its child input is checked. <div> <!--- this is the parent element ---> <input type="radio" data-dynamic-update="1" name="virtuemart_paymentmethod_id" id="payment_id_3" value= ...

I would like to create a border for the radial gradient and apply it to the div as well

Below is the CSS code I have written. div { height: 150px; margin: 5em 2em; background: radial-gradient(circle at top center, transparent, transparent 70px, black 70px, black); border-radius: 8p## Heading ##x; position: relative; } .circle { ...

Angular 8 can sometimes cause CSS to become disorganized upon page load

In the process of developing my angular project, I've integrated pre-designed HTML templates. Implementing lazy loading for page loading has led to an issue where the CSS appears distorted, as shown in the attached gif image. https://i.sstatic.net/7UZ ...

"Encountering an 'Unexpected string' error when trying to implement a

$('.star').mouseover(function (){ var starIndex = $(this).index()1; $(this).parent().css("background-position", "0 -" + (32 * starIndex) + "px"); }); $('.star-rating').mouseout(function (){ var originalResult = $(this).attr ...

Using CSS to style HTML elements with spaces

Apologies if this question can easily be answered with a Google search, but I am having trouble finding the right keywords to use. While I have a decent grasp of CSS, I feel like there is still much more potential to explore and improve my code efficiency. ...

What is the best way to initiate an image loop with the click of a button?

<p align="center"> <button onclick="slideit()">Run the loop</button> <!-- Start Weather Image Loop --> <img src="firstcar2.gif" name="slide" width="900" height="500" /> <script type="text/javascript"> <!-- var ...

Two tables are refusing to stack on top of each other

I have encountered an issue while trying to construct a website using bootstrap. The problem lies in the layout of two tables that appear stacked on top of each other instead of being positioned next to each other. Despite my attempts at various solutions, ...

Assign the value of an element in an array to a variable using jQuery

https://i.sstatic.net/RtzeT.png In the jQuery variable, I have received an array and now I am looking to store each array value in a different variable. For example, I want to store the Address field in one variable. How can I achieve this? Any suggestion ...

Placing an image on the chosen option of a <mat-select> using Angular Material

I have incorporated Angular Material into my Angular 2 project, and I am trying to insert a static image (HTML element) in the selected value of mat-select. Unfortunately, I have been unable to find a solution for this issue. Is there anyone who can ...

Leverage ajax and grails to dynamically showcase a linked database entry based on a user's selection

Is there a way to select multiple values (IDs) from a database and display them by associated name while saving the ID attached to each selected value (name)? I inquired if this could be done using jQuery, but was advised that Ajax might be a better option ...

Secure your DOM's href attribute from prying eyes

I have a display page that shows all of our reports in the following format: https://i.sstatic.net/lNzH8.png When hovering over a report, it displays the file's URL (where it is located on our server). I want to prevent users from accessing this inf ...