스크립트
< 자료공유 < 스크립트
스크립트자료실

로그인 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 값과 일치해야함.

  • 페이스북으로 보내기
  • 트위터로 보내기
  • 구글플러스로 보내기