Change the text colour and background colour of a TextBox using onfocus() and onBlur() event.
<html>
<body>
Enter text :
<input type="text" id="txtbox" onfocus=change(0) onblur=change(1)>
<script>
function change(i) {
if (i == 0) {
document.getElementById("txtbox").style.backgroundColor = "lightgrey";
document.getElementById("txtbox").style.color = "blue";
}
else {
document.getElementById("txtbox").style.backgroundColor = "white";
document.getElementById("txtbox").style.color = "black";
}
}
</script>
</body>
</html>
Output



thank you so much its helpful