Internet Explorer 11 does not update the content of pseudoelements

I've come across a strange issue with my code. Here is what I have:

someSelector:after {
  content: attr('data-some-data');
  /* ... */
}

Initially, everything works perfectly fine (the value is displayed on the screen) until I decide to change this attribute to something else:

document.querySelector('someSelector').dataset.someData = 'some other value';

Oddly enough, the content does not update on the screen even though the DOM explorer clearly shows that the attribute value has been updated.

I attempted to manually set it through the browser console as well, but still no luck.

Interestingly, everything functions correctly in other browsers, except for IE... you know how it goes.

The Burning Question

So here's the million-dollar question: Can I somehow force an update of this value so that it reflects on the screen when altered?

Answer №1

It's puzzling that IE11 fails to update the DOM when you modify an element's dataset.

If you must cater to IE11, consider using the Element.setAttribute method like this:

document.querySelector('someSelector').setAttribute('data-some-data', 'some other value');

By doing so, the DOM should be refreshed and the pseudoelement content ought to reflect the changes made.

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

Avoiding line wrapping can be achieved by hiding elements using the d-none class from Bootstrap

During the development of a responsive website, I encountered an issue with the topbar menu. The menu contains numerous options, which is ideal for larger screens. However, on smaller viewports like cellphones, the buttons start wrapping rather than fittin ...

Not all properties are affected by the CSS stylesheet

Even though my CSS stylesheet successfully changes the background color of the page, I am facing issues with other properties that I have set on my HTML tags. {% block body %} <div id='title'> <h1> VISUALIZER2D ...

The distinction between using document.getElementById and document.getElementsByClassName in JavaScript

One thing that stands out is why does document.getElementsById function as expected here <div id="move">add padding</div> <button type="button" onclick="movefun()">pad</button> <script> function movefun() { document.get ...

Observing changes in the dimensions of flex children using MutationObserver

Considering the following structure of the Document Object Model... <div id="outer-container"> <div class="side-panel"><div width="200px"/></div> <div id="content"><!-- some content --></div> <div class=" ...

Creating a responsive Image for desktop screens with the help of Tailwind and nextJS

I'm currently working on a component that displays a set of images with horizontal scroll. The challenge I'm facing is setting different dimensions for mobile/tablet screens and desktop screens. For mobile and tablet, I want the images to be disp ...

Chrome is able to interpret Behat CSS selectors, whereas Firefox struggles with them

Recently I began working with Behat and Selenium for website test automation. One issue I've encountered is that some CSS selectors work in Chrome but not in Firefox. For instance, in my Behat code: Then I press ".topmember-resultList .resultListIte ...

Arranging elements on a webpage using CSS grid placements

Currently experimenting with css grid, envisioning a scenario where I have a 2x2 grid layout. When there are 4 child elements present, they would form 2 rows of 2 elements each. My challenge is when dealing with an odd number of children, I aim to avoid al ...

Having a bottom border only on input fields appears strange when viewed on a mobile device

When trying to achieve a bottom border on mobile, I encountered an unexpected issue where a strange line appeared instead in the browser. Here is an image of the problem: https://i.sstatic.net/PqEOF.jpg I expected to see a straight line as intended (it w ...

Create a visually appealing layout with two images positioned side by side using Bootstrap

Currently, I am working with a code snippet that displays two images, each approximately 350px wide. These images are being shown in a sidebar that is set at 400px wide on desktop and tablet screens (col-lg, col-md, col-sm), but expands to 100% width on a ...

Using HTML and CSS to stack a DIV on top of another using z-index

I have 3 main layers on my website: 1) The main view with elements inside (#views in jsbin) - BOTTOM LAYER 2) An overlay (with a white background opacity of .8 #overlay in jsbin) - MIDDLE LAYER 3) A context menu (#contextmenu in jsbin) - TOP LAYER Wh ...

Tips for creating CSS3 animations in Angular triggered by mouse clicks

I'm working with a span that utilizes a Bootstrap icon. My goal is to fade out and fade in the same element (span) on click, while toggling the class (icon). There's a boolean variable called showLegend which determines whether or not to animate ...

Combining Javascript and Django for a powerful web development solution

Having trouble setting up JS on my Django web app, despite reading through the documentation and previous queries. Using the Django dev server with the following file structure: mysite/ __init__.py MySiteDB manage.py settings.py ...

Bootstrap 4.6 - new feature: flexible vertical pills and sleek horizontal tabs (inactive tab no longer highlighted)

I recently implemented Bootstrap 4.6 into my project. The page I am working on includes both vertical pills and horizontal tabs. While the vertical pills are displaying correctly, I have encountered an issue with the styling of the horizontal tabs when th ...

Having trouble with multiple slideshows not functioning correctly. Any ideas on how to fix this

My current challenge involves setting up multiple slideshows on a single page with navigation dots to switch between each slideshow. The issue arises when I try to incorporate more than one slideshow, as the navigation dots either stop working or begin con ...

Fixed Navbar at the top of the page with no elements underneath

Currently, I am working on creating a sticky navbar for a school project website. You can check out the site here: I am aiming to ensure that the content does not overlap with the navbar when scrolling. I want the content to appear beneath the navbar as i ...

How can you generate an HTML table row without using the <tr>

Greetings everyone! I am currently working on creating a table using HTML, Bootstrap 5, and CSS to display various article details. Each article may have one or multiple variants, and I would like these variants to be displayed as rows within the parent ar ...

Table positioned with a slight gap between its edges and the browser border

I am facing an issue with a table that extends beyond the browser edges, and I am unsure how to fix this. Here is the code snippet for the table: It's important to note that I am using PHP. function create_Chat_Table($text){ $pseudo=$_GET['D ...

Can you explain the significance of the ">" symbol within CSS coding?

Seeking some quick points for those in the know. Can someone provide a thorough explanation of the meaning and proper usage of the > symbol? Appreciate it. ...

Conflicting styles between Bootstrap and Formstack are causing radio buttons to appear only partially visible

Encountering a conflict between Bootstrap (4.1.3) and Formstack CSS when trying to embed a form in a website. The radio buttons are not fully visible, with the issue located in the "label" class ("fsOptionLabel"). Adjusting the line height provides a parti ...

The `margin:auto;` property does not function properly with inline-block elements

I recently adjusted my "container" div by changing it to an inline-block. Previously, I had applied margin:auto; to center it, which worked well with a specified width. Original Code (functional) #container { border: 1px solid black; height: 2 ...