본문 바로가기

프로그래밍

[JavaScript] html 클릭 시 공백으로 초기화 - javascript 이용

html의 텍스트 필드 값을 공백으로 초기화 하는 방법입니다.

 

초기값이 미리 선언되어 있는 경우 필요한 기능이죠.

 

onclick="javascript:document.폼 네임.필드 네임.value=''"

 

이 코드를 추가하면 됩니다.

 

ex)

 

<input type="text" name="test" onclick="javascript:document.hello.test.value=''"/>

 

 

=============================

개인 참고 코드

<input type="text" id="test" name="test" style="width:100%" maxlength="20"onclick="javascript:document.hello.test.value=''"/>