js input清空输入值并还原默认值

mac2022-06-30  78

<script type="text/javascript"> function clearDefaultText(el, message) { var obj = el; if (typeof(el) == "string") obj = document.getElementById(id); if (obj.value == message) { obj.value = ""; } obj.onblur = function() { if (obj.value == "") { obj.value = message; } } } </script>

<input type="text" value="验证码" οnclick="clearDefaultText(this,'验证码')" />

 

转载于:https://www.cnblogs.com/txhy/p/4941821.html

最新回复(0)