Change placeholder color in Javascript for Chrome
As said here : Change an HTML5 input's placeholder color with CSS, Chrome doesn't support the CSS property color for input placeholders.
But there is a property named -webkit-input-placeholder
. If I put on my CSS :
#MyInput::-webkit-input-placeholder {
color: blue;
}
It works. But how can I do this with Javascript (or jQuery) ?
Define it in the CSS as you have it, but make it #MyInput.blue-placeholder::-webkit-input-placeholder
and add/remove the "blue-placeholder" class with jQuery.
#MyInput.blue-placeholder::-webkit-input-placeholder {
color: #0000ff;
}
DEMO: http://jsfiddle.net/AY3j6/
链接地址: http://www.djcxy.com/p/70462.html