bobojavascript中onblur和onfocus
<script type="text/javascript">
function cls() {
//捕获触发事件的对象,并设置为以下语句的默认对象
with (event.srcElement)
//如果当前值为默认值,则清空
if (value == defaultValue) value = ""
}
function res() {
//捕获触发事件的对象,并设置为以下语句的默认对象
with (event.srcElement)
//如果当前值为空,则重置为默认值
if (value == "") value = defaultValue
}
</script>
<input value="填写您的昵称" onfocus="cls()" onblur="res()"/>
<input value="填写您的生日(1900-01-01)" onfocus="cls()" onblur="res()"/>