Demuri Celidze Demuri Celidze - 2 months ago 24
CSS Question

How to replace pseudo class :placeholder-shown with jquery

I have a form where

<label>
changes on
input:placeholder-shown
(https://jsfiddle.net/Moor/3r1uL9n6/). Works fine, but in only few browsers. How to add and remove some class with jQuery to replace this not-cross-browser
input:placeholder-shown
?

Answer
You can use jQuery:

$("#my_input").on("keydown keypress keyup paste", function () {

    var textColor = $(this).val() ? "red" : "green";

    $("div label").css({"color" : textColor});

});