On Click Page Theme Change

by Santosh Thakur

HTML

<form action="" id="myForm">
<input id="myInput" type="text" value="Search">
</form>

JavaScript

var x = document.getElementById("myForm");
x.addEventListener("focus", myFocusFunction, true);
x.addEventListener("blur", myBlurFunction, true);

function myFocusFunction() {
  document.getElementById("myInput").style.backgroundColor = "yellow";
  document.getElementsByTagName("body")[0].style.backgroundColor = "#ffcc00";
}

function myBlurFunction() {
  document.getElementById("myInput").style.backgroundColor = "";
  document.getElementsByTagName("body")[0].style.backgroundColor = "";
}