The :after pseudo class is malfunctioning on browsers other than Chrome

While using JQuery, I encountered an issue with error checking that involves adding a class to an <input> checkbox. This class includes an :after pseudo-class which is designed to display additional information, but for some reason, it doesn't show up as expected.

I have attempted various solutions to resolve this issue, but so far, no luck. You can view the website where I am working on this problem here: SITE

The only logical explanation I can think of for this malfunction is that perhaps the page needs to be refreshed after the new class addition, although in other instances where I add a new class, everything functions correctly.

The error check triggers when the checkbox is checked without selecting a scanner.

Below is the relevant code snippets:

HTML

<form id="lp5_form" class="prodForm">
    <label><span>Apple Product: </span><select class="model">
                            <option value="0">iPod 5</option>
                            <option value="1">iPhone 5</option>
                         </select></label>
    <label style="padding: 10px 0;"><h4>Sled Options :</h4></label>
    <table>
        <tr>
            <td>Encryption Capability: </td><td><select class="encryption">
                                                   <option value="0">Standard</option>
                                                   <option value="1">SRED for PCI Compliancy</option>
                                                 </select></td>
        </tr>
        <tr>                                         
            <td>Scanner: </td><td><select class="scanner">
                                    <option value="0">None</option>
                                    <option value="1">1D</option>
                                    <option value="2">2D</option>
                                  </select></td>
        </tr>
        <tr>
            <td>Bluetooth: </td><td><input class="bt" type="checkbox" value="bluetooth" /></td>
        </tr>
    </table>
</form>

CSS

.pn_error{}

.pn_error:after, .pn_error::after {
    content: "*Please select a scanner";
    color: red;
    position: relative;
    display: block;
    width: 200px;
    left: 20px;
    top: -2px;
    font-size: 12px !important;
}

JQUERY Error Check

if(scanner == 0) {
    bt = 0;
    $(id+' .bt').addClass('pn_error');
}

Any assistance or insights on addressing this issue would be greatly appreciated.

Answer №1

:after is actually a pseudo-element, not a pseudo-class. Due to this nature, it cannot be used on elements that do not support child elements. This means no img:after, no br:after, and no input:after.

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

How to use AngularJS ng-repeat to generate a mailto hyperlink

Currently, I am displaying our user list using ng-repeat. <div ng-repeat="User in ac.Users | filter:ac.Search | limitTo:ac.Limit" style="{{ac.Users.indexOf(User)%2 == 0 ? 'background-color:#f2f2f2' : 'background-color:white' } ...

Issue with Angular ngFor binding. What could be causing this error to occur?

I have a main component called DOCUMENT. This document receives a URL segment and retrieves an array of associated objects from my database. Then, using @Output() documents = new EventEmitter() and an @Input() in a DOCUMENT VIEW component, I loop through t ...

I am having trouble uploading the style.css file in CodeIgniter and I really need to incorporate that styling into my views. Can anyone advise on how to include style.css in the views

I'm encountering an issue trying to upload the style.css page in codeigniter and I need that styling information within the views file. How can I include style.css in my views? This is the content of my style.css page: body { margin: 0; padd ...

Positioning Images at the Top of the Screen in React Native

I have two images that I would like to display side by side at the top of the screen. <View style={styles.container}> <View style={styles.topWrapper}> <Image source={TOP_START_GRAPHIC} style={styles.topStartImage} /> ...

What is the best way to add a CSS rule to JavaScript?

animation: scaleUp 0.3s linear 0.4s forwards; animation: scaleDown 0.3s linear forwards; Greetings! I'm currently working on adding animations to my content filtering functionality. Specifically, I want to incorporate the aforementioned CSS rules in ...

JavaScript News Scroller for Horizontal Display

After searching through numerous websites, I have yet to find the ideal horizontal news scroller for my website. My specific requirements include: Must provide a smooth scrolling experience Scroll from right to left covering 100% width of the browser ...

JavaScript: Creating a new entry in a key-value paired array

I am in the process of creating a dynamic menu for use with jQuery contextMenu. I have encountered an issue when trying to add a new element, as it keeps showing the error message 'undefined is not a function'. The menu functions correctly witho ...

The HTML background color is refusing to change

I've been struggling to tweak the background color of a specific page. I attempted setting the HTML as the background color, using !important, but unfortunately, it didn't yield the desired result. The same goes for trying to set the background c ...

Having trouble with Django when attempting to move a portion of a string to a new line

When a user signs up in my Django project and makes a mistake, an error message is sent to the template for display. I've noticed that some of my error messages are too long and need to be displayed on multiple lines within the text. I tried adding &b ...

Discovering the file size using jQuery from a download link

Is there a way to utilize jQuery to determine the file size of a PDF that is linked to a webpage? I am looking to create a feature where, upon hovering over the download link, a modal box displays indicating the file size of the PDF. I have the second par ...

tips for implementing word-breaking in css

I encountered a problem on my support ticket page where the message text was overflowing out of the designated grey container. Despite trying to utilize the "word-wrap" CSS class, the issue persisted. Here's the code snippet with placeholders for vari ...

Working with Thymeleaf and DatePicker to establish a minimum date

Looking to establish a minimum selectable date in my datepicker using Thymeleaf. Attempted code: <label th:utext="#{${name}}" th:for="${name}" class="control-label"></label> <div class="input-group input-group-prepend"> <span cla ...

`Is it possible to animate the rotation of an image within an input control?`

After coming across this helpful answer, I successfully added a rotating GIF image as an icon inside an INPUT control on its right side. Simply applying the "busy" class to my control did the trick, and now it looks like it's in progress. input.busy { ...

Arrange two tables side by side horizontally using CSS styling

I'm new to CSS and looking for help on how to format a table to appear as two distinct tables side by side. I want the brown cells to be brown and the rest blue. https://i.sstatic.net/NrbsU.png Here is my attempt so far, but I'm struggling with ...

Retrieve the outcome of an Ajax request

Hey there, I have a situation where I need to submit a form and make an ajax call. Here's what I'm doing: $('#pForm').on('submit', function(e) { e.preventDefault(); //Prevents default submit var form = $(this); var post ...

Is there a way to change the button image dynamically by toggling between various font-awesome icons?

I'm working on implementing a button that switches between displaying a font-awesome icon for "Run" and "Pause" every time the user clicks on it. Can someone provide guidance on the syntax required for achieving this behavior in an Angular applicatio ...

Photoshop optimized webpage appearing distorted on Internet Explorer after saving for web

I designed a webpage using Photoshop, sliced it, saved it for the web, and uploaded the HTML file. It looks great in Firefox and Chrome, but Internet Explorer tells a different story. Does anyone know how to fix it and why there is this black padding? IE: ...

Guide to serializing an array with JavaScript utilizing Web.api

I seem to be encountering a problem when trying to post an array to a web.api (api controller) in its simplest form. Here is the JavaScript code I have: var ann = { Age: 11, Name: 'Ann' }; var bob = { Age: 22, Name: 'Bob' }; var list ...

Steps to turn off fancybox for mobile and show the full image instead

In this scenario... I am seeking a way to deactivate fancybox functionality on mobile devices. I have already discovered one method to disable it... And now I want to directly show the large image in the a href="xxx_large.jpg" instead of using the img src= ...

Ways to include additional details in each row of an autocomplete feature

I have successfully implemented autocomplete for venues worldwide, but now I want to display the address of each venue below its name. For example, if the autocomplete suggests the venue name as ABCD, I want the address of that venue to appear right benea ...