Why doesn't initial page focus change input field to Green on Google Chrome?
http://stackoverflow.com/questions/6951587/why-doesnt-initial-page-focus-change-input-field-to-green-on-google-chrome/6951855
by beckje01
HTML
<input id="Txt1" runat="server" class="InputField"/><br />
<input id="Txt2" runat="server" class="InputField"/><br />
<input id="Txt3" runat="server" class="InputField"/><br />
CSS
.InputField
{
color: black;
font-size: 12px;
font-weight: bold;
background-color: #7AC5CD;
}
JavaScript
function Change(obj, evt) {
console.log(obj)
console.log(evt)
if (evt.type == "focus" || evt.type == "load") {
obj.style.borderColor = "black";
obj.style.backgroundColor = "#90EE90"; // light green on focus
}
else if (evt.type == "blur") {
obj.style.borderColor = "white";
obj.style.backgroundColor = "#7AC5CD"; // light blue on blur
}
}
$(document).ready(function() {
$("#Txt1").focus(function() {
Change(this, event)
});
$("#Txt2").focus(function() {
Change(this, event)
});
$("#Txt3").focus(function() {
Change(this, event)
});
$("#Txt1").blur(function() {
Change(this, event)
});
$("#Txt2").blur(function() {
Change(this, event)
});
$("#Txt3").blur(function() {
Change(this, event)
});
$("#Txt1").focus();
});