Believe me, you need vendor prefixes (From css-tricks.com):
::-webkit-input-placeholder { color: red; } :-moz-placeholder { color: red; } ::-moz-placeholder { color: red; } :-ms-input-placeholder { color: red; }
Using javascript, you will apply program style (using vendor prefixes) at the focus event.
Edit: In fact, these styles that I don't think can be applied using javascript. You will need to create a class and apply it using js.
CSS
input.placeholderred::-webkit-input-placeholder { color: red; }
JQuery
var $textInput = $('#TextField1'); $textInput.on('focusin', function () { $(this).addClass('placeholderred'); } ); $textInput.on('focusout', function () { $(this).removeClass('placeholderred'); } );
JS:
var textInput = document.getElementById('TextField1'); textInput.addEventListener('focus', function () { this.classList.add('placeholderred'); } ); textInput.addEventListener('blur', function () { this.classList.remove('placeholderred'); } );
And the courtesy of the most useful, Armfoot, violin: http://jsfiddle.net/qbkkabra/2/
source share