Home > Web Front-end > JS Tutorial > Implementing mouse click on text box to display and hide prompt text based on JQuery_jquery

Implementing mouse click on text box to display and hide prompt text based on JQuery_jquery

WBOY
Release: 2016-05-16 17:55:58
Original
1285 people have browsed it

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:

Copy the code The code is as follows:

$(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)
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template