JS文本框默认值处理详解
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:functiontxtFocus(el){if(el.defaultValue==el.value){el.value='...
复制代码 代码如下:
<script type="text/javascript">
function txtFocus(el) {
if (el.defaultValue == el.value) { el.value = ''; el.style.color = '#000'; }
}
function txtBlur(el) {
if (el.value == '') { el.value = el.defaultValue; el.style.color = '#666'; }
}
</script>
<asp:TextBox ID="txtBookPerson" runat="server" CssClass="text2" onfocus="txtFocus(this)" onblur="txtBlur(this)" value='请输入预定人' ></asp:TextBox>