How to solve the problem of text position jumping when the focus of the search text box leaves
This article focuses on "how to solve the problem of text position bouncing when the focus of the search text box leaves". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to solve the problem of text position bouncing when the focus of the search text box leaves.
The code is as follows:
/ / search text box
$("# txtSearch") .focus (function () {
If ($(this) .val () = "Please enter a search keyword") {
$(this) .val ("")
(this) .css ("color", "black")
}
}) .blur (function () {
If ($(this) .val () = "") {
$(this) .css ("color", "gray") .val ("Please enter search keywords")
}
});
Add to css
The code is as follows:
# txtSearch
{
Width:480px
Height:20px
Vertical-align:middle
}
At this point, I believe you have a deeper understanding of "how to solve the problem of text position jumping when the focus of the search text box leaves". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!