<input type="text" name="foo" onfocus="this.style.backgroundColor='rgb(200,200,200)';" onblur="this.style.backgroundColor='white';">
...eller?
4 svar · 180 visningar · startad av Jesper T
När jag klickar i ett textfält så skall bakgrunden bli grå och när jag klickar utanför så skall alla textfält bli orginalvita.
Tips?
<input type="text" name="foo" onfocus="this.style.backgroundColor='rgb(200,200,200)';" onblur="this.style.backgroundColor='white';">
...eller?
Tack funkar bra!
Jag har en hel skrälldus med inputfält går det att lägga in i ett script i head på någe vis?
<body onload="init();">
<script language="JavaScript" type="text/javascript">
function init(){
for(var i=0;i<document.forms[0].length;i++){
document.forms[0].elements[i].onfocus=function(){ this.style.backgroundColor="rgb(200,200,200)"; }
document.forms[0].elements[i].onblur=function(){ this.style.backgroundColor="white"; }
}
}
</script>
<form action="something.asp" method="post">
<input type="text" name="foo">
<input type="text" name="bar">
</form>
Bussigt! Det blev jättefint!