로그인 input box안에 이미지 사용. 클릭시 사라지기
페이지 정보
작성일13-02-27 23:55 조회2,611회본문
<script>
function chgBGimg(obj, s2)
{
var sobj;
var imgsrc;
sobj = obj.style;
if(obj.name == "id")
imgsrc = "url(/images/id.gif)";
else
imgsrc = "url(/images/pw.gif)";
if(s2 == "1")
sobj.backgroundImage = "";
else
{
if(obj.value == "")
sobj.backgroundImage = imgsrc;
}
}
</script>
<li><label for="id"></label> <input type="text" id="top_id" class="log_text" style="width:110px;" onfocus="chgBGimg(this, '1')" onblur="chgBGimg(this, '0')" style="background-image:url('/img/idbg.gif'); name='id'/></li>
<li><label for="pw"></label> <input type="password" id="top_pw" class="log_text" style="width:110px;" onKeyDown="top_enter(event);" onfocus="chgBGimg(this, '1')" onblur="chgBGimg(this, '0')" style="background-image:url('/img/pwbg.gif'); name="pwd" /></li>
obj.name 값이 input name 값과 일치해야함.
function chgBGimg(obj, s2)
{
var sobj;
var imgsrc;
sobj = obj.style;
if(obj.name == "id")
imgsrc = "url(/images/id.gif)";
else
imgsrc = "url(/images/pw.gif)";
if(s2 == "1")
sobj.backgroundImage = "";
else
{
if(obj.value == "")
sobj.backgroundImage = imgsrc;
}
}
</script>
<li><label for="id"></label> <input type="text" id="top_id" class="log_text" style="width:110px;" onfocus="chgBGimg(this, '1')" onblur="chgBGimg(this, '0')" style="background-image:url('/img/idbg.gif'); name='id'/></li>
<li><label for="pw"></label> <input type="password" id="top_pw" class="log_text" style="width:110px;" onKeyDown="top_enter(event);" onfocus="chgBGimg(this, '1')" onblur="chgBGimg(this, '0')" style="background-image:url('/img/pwbg.gif'); name="pwd" /></li>
obj.name 값이 input name 값과 일치해야함.