PDA

View Full Version : onClick remove background image of text field


bakitc
10-10-2007, 09:58 AM
Hi,

I am looking for Javascript coding which removes the background image I have in my text field when a user clicks on it to enter text.

Is this possible?

Appreciate your time!

coothead
10-10-2007, 11:24 AM
Hi there bakitc,

try it like this...
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
input {
background-image:url(http://mysite.orange.co.uk/azygous/images/anim2.gif);
border:2px solid #606;
}
</style>

<script type="text/javascript">
window.onload=function() {
document.forms[0][0].onfocus=function() {
this.style.backgroundImage='none';
}
}
</script>

</head>
<body>

<form action="#">
<div>
<input type="text"/>
</div>
</form>

</body>
</html>