본문 바로가기

javascript

자바스크립트 기본 예제(아이디 이미지)

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

<script type="text/javascript">

function bgImage() {

var f=document.forms[0];

if(f.id.value){

f.id.style.backgroundImage="";

}else{

f.id.style.background="url(/study/img/loginID.gif) no-repeat 3px 3px #ffffff";

}

}


</script>

</head>

<body>


<form action="">

<input type="text" size="15" maxlength="15"

name="id"

style="background: url(/study/img/loginID.gif) no-repeat 3px 3px #ffffff"

onfocus="this.style.backgroundImage='';"  

onblur="bgImage();"><br/>

<input type="password" size="15" maxlength="15" name="pwd">


</form>


</body>

</html>