For example, the search box on my website:
When not in use:
After mouse click:
It is very simple to achieve this effect with JQuery. The following is the code:
$(document).ready(function () {
var searchBox = $("#ctl00_txtSearch");
searchBox.focus(function () {
if (searchBox.val() = = this.title) { // The ToolTip property of the TextBox control is converted into Html as the title property
searchBox.val("");
}
});
searchBox.blur(function () {
if (searchBox.val() == "") {
searchBox.val(this.title);
}
});
searchBox.blur();
});
where #ctl00_txtSearch is the ID of the search box (ASP.NET can obtain this ID through ClientID)
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn