내 onblur/onfocus HTML 코드를 Javascript 함수로 대체하는 방법을 알고 싶습니다. 또한 select 옵션과 동일한 기술을 수행합니다.onblur 및 onfocus 도움말 - Javascript function alternative
코드 예제 : 당신이 엄격 같은 사소한 UI 요소에 오래된 브라우저를 지원하도록 강요하지 않는 경우
<table>
<tr><td>
<label for="firstname">*Firstname:</label>
<input type="text" name="udetail" id="firstname" value="(e.g. John)"
onblur="if(this.value == '') { this.style.color='#999'; this.value='(e.g. John)'}
{this.style.border='1px #bbb solid'}" onfocus="if (this.value == '(e.g. John)')
{this.style.color='#000'; this.value=''}" tabindex="1" />
</td></tr>
<tr><td>
<label for="where">*How did you hear about us:</label>
<select size="1" name="udetail" id="where" class="input"
tabindex="7" />
<option value="blank">Select</option>
<option value="ampdj">AMPdj</option>
<option value="bing">Bing</option>
<option value="google">Google</option>
<option value="pastfunction">Past function</option>
<option value="recomended">Recomended</option>
<option value="yell">Yell</option>
<option value="other">Other</option>
</select>
</td></tr>
</table>
감사합니다, 스콧
왜 JavaScript를 작성하지 않고 자리 표시 자 속성을 사용하지 않는 이유가 있습니까? – lifetimes
방금 placeholder 속성을 사용해 보았지만 위의 코드와 같은 방식으로 수행하지 않습니다 ... – user2428136