How to change the color of placeholder when focus the input field? I use this css to set the default color, but how to change it on focus?
::-webkit-input-pl
This works for me:
input:focus::placeholder {
color: blue;
}
From Firefox 19: The :-moz-placeholder pseudo-class that matches form elements with the placeholder attribute has been removed, and the ::-moz-placeholder pseudo-element has been added instead.
input:focus::-moz-placeholder { color: transparent; }
Try this, this should work :
input::-webkit-input-placeholder {
color: #999;
}
input:focus::-webkit-input-placeholder {
color: red;
}
/* Firefox < 19 */
input:-moz-placeholder {
color: #999;
}
input:focus:-moz-placeholder {
color: red;
}
/* Firefox > 19 */
input::-moz-placeholder {
color: #999;
}
input:focus::-moz-placeholder {
color: red;
}
/* Internet Explorer 10 */
input:-ms-input-placeholder {
color: #999;
}
input:focus:-ms-input-placeholder {
color: red;
}
Here is an example : http://jsfiddle.net/XDutj/27/
The following worked for me:
input:focus::-webkit-input-placeholder
{
color: red;
}
Try this:
HTML
<input type='text' placeholder='Enter text' />
CSS
input[placeholder]:focus { color: red; }
Use star *
to select everything
*::-webkit-input-placeholder { color: #999; }
*:-moz-placeholder { color: #999; }
*::-moz-placeholder { color: #999; }
*:-ms-input-placeholder { color: #999; }