搜索框文本 - 显示隐藏功能 [英] Search Box Text - Show Hide Feature

查看:74
本文介绍了搜索框文本 - 显示隐藏功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Chris Coyer的网站上,他使用了一个漂亮的小搜索框。我很想知道如何让搜索框中的文字消失,并在您点击开箱后重新显示。

On Chris Coyer's site he uses a nice little search box. I am curious to know how you get the text in the search box to disappear and reappear when you click out of the box.

感谢在此论坛上有用的人使用以下内容使文本在单击框中​​消失:

Thanks to a helpful person on this forum I use the following to have the text disappear when I click in the box:

<input type="text" value="Search" onfocus="if (this.value=='Search') this.value='';"/>

此外,在Safari中,当我单击内部时,输入字段周围有一个讨厌的边框。

Also, in Safari there is a nasty border around the input field when I click inside. What is the code for getting rid of that?

谢谢!

推荐答案

p>我不相信你可以删除Safari中的边框,虽然打开以更正。

I do not believe you can remove the border in Safari, though open to corrections.

要使文本再次出现在您点击搜索框,你可以使用这个:

To get the text to appear again when you click out of the search box, you can use this:

<input onblur="if (this.value == '') this.value ='Search';" />

这篇关于搜索框文本 - 显示隐藏功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆