=====================================================
<HTML>
<HEAD>
<style type="text/css">
.OnFocus
{
background-color : gray;
}
.OnBlur
{
background-color : white;
}
</style>
<script language="javascript" type="text/javascript">
function SetStyle()
{
var elem = document.getElementById('frmMain').elements;
for(var i = 0; i < elem.length; i++)
{
// Assing style to each and every textbox on this page.
if (elem[i].type == "text")
{
elem[i].setAttribute("onfocus","this.className = 'OnFocus';");
elem[i].setAttribute("onblur","this.className = 'OnBlur';");
}
}
}
</script>
</HEAD>
<BODY onload="javascript:SetStyle()">
<form id="frmMain" >
<input type="text" value="Hello 1" id="text1" /> <br/>
<input type="text" value="Hello 1" id="text2" /><br/>
<input type="password" value="Hello 1" id="text1" /> <br/>
</form>
</BODY>
</HTML>
That's It !
Hope you will like it.
0 comments:
Post a Comment