Question

Using JQuery I have an error check that adds a class to an <input> checkbox. That has an :after pseudo class, but the information displayed by that class doesn't appear.

Tried a couple of things to get it to work, but no dice. This is the site I am working on: SITE

The only other reason that I can think of for this not to work is that the page would need to be refreshed with the addition of a new class...but everything else that I add a new class to it works.

The error check appears when the checkbox is checked and there is no scanner selected.

Here is all of my relevant code:

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');
}

As usual all help is greatly appreciated.

Was it helpful?

Solution

:after is a psuedo-element, not a psuedo-class. As such, they cannot be applied to element that do not allow children. So no img:after, no br:after, and no input:after.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top