I tried to change the color of the placeholder by adding a new class, so that the color property is overwritten. However, it does not seem to work. Following code is intended to change the placeholder color from green to red, however it is changed from green to default black/gray.
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <input class="class" id="id" type="" name="" placeholder="placeholder text"> </body> <style type="text/css"> .class::-moz-placeholder { /* Mozilla Firefox 19+ */ color: green; } .class2::-moz-placeholder { color: red !important; } </style> <script type="text/javascript">document.getElementById("id").className+="class2";</script> </html>
Where is the mistake or which alternative does work?
.className += ' class2'
. Why not just replace the class though? There's nothing inclass
that isn't inclass2