- <input type="text" id="textBoxVal" />
- document.getElementById("textBoxVal").focus();
- document.getElementById("textBoxVal").style.backgroundColor = "lightsalmon";
-
- $("#textBoxVal").keyup(function() {
- var inputVal = document.getElementById("textBoxVal").value;
- if (inputVal == "") { document.getElementById("textBoxVal").style.backgroundColor = "lightsalmon";
- }
- else {
- document.getElementById("textBoxVal").style.backgroundColor = "white";
- }
-
-
- });
For more check the fiddle lik below:
http://jsfiddle.net/SurajMindfire/nx0to9gb/
This will surely help in use of selectors also.
Thanks