网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

如何设置textarea清除按钮

时间:2024-10-13 21:46:30

1、浏览一些Blog时,会看到在留言框、搜索栏或者Email订阅栏中有一段默认的文本,比如“Type your comment here”

如何设置textarea清除按钮

2、如果你在其中点击(窗体获取焦点),这段默认的文本就会自动消失。实现这种效果非常简单: 在Header.php中添加如下脚本:<head>

如何设置textarea清除按钮

3、//脚本要放在head标签里面<script type="text/javascript"> function clearDefault(el) {if (el.defaultValue==el.value) el.value = ""

如何设置textarea清除按钮

4、</script>...</head>如果是输入栏(Input),在其中添加一个onfocus参数,如:<input type="text" id="input_email_address" name="email" class="input" value="Your Email Address"

如何设置textarea清除按钮

5、onfocus="clearDefault(this)" />如果是文本域,添加的onfocus参数如下:<textarea name="comment" id="input_comment" rows="10" class="input textarea"

如何设置textarea清除按钮

6、onfocus="this.value=''; this.onfocus=null;" >Type your comment here</textarea>

如何设置textarea清除按钮如何设置textarea清除按钮
© 2025 一点资料
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com