Solution to the problem of text position jumping when the search text box leaves the focus

Solution to the problem of text position jumping when the search text box leaves the focus

When setting the text in the search text box, the position jumps when leaving the focus

Copy code
The code is as follows:

//Search text box
$("#txtSearch").focus(function () {
if ($(this).val() == "Please enter the search keyword") {
$(this).val("");
$(this).css("color", "black");
}
}).blur(function () {
if ($(this).val() == "") {
$(this).css("color", "gray").val("Please enter the search keyword");
}
});

Add in css

Copy code
The code is as follows:

#txtSearch
{
width:480px;
height:20px;
vertical-align:middle;
}

<<:  How to implement horizontal bar chart with percentage in echarts

>>:  Teach you to quickly build a web cluster project based on nginx

Recommend

JavaScript using Ckeditor + Ckfinder file upload case detailed explanation

Table of contents 1. Preparation 2. Decompression...

Ubuntu Server Installation Tutorial in Vmware

This article shares with you the Ubuntu server ve...

How to regularly clean up docker private server images

Using CI to build docker images for release has g...

Detailed explanation of Linux tee command usage

The tee command is mainly used to output to stand...

Pitfall notes of vuex and pinia in vue3

Table of contents introduce Installation and Usag...

How to install theano and keras on ubuntu system

Note: The system is Ubuntu 14.04LTS, a 32-bit ope...

React Diff Principle In-depth Analysis

Table of contents Diffing Algorithm Layer-by-laye...

Detailed analysis of the MySQL slow log opening method and storage format

In development projects, we can monitor SQL with ...

Example analysis of mysql variable usage [system variables, user variables]

This article uses examples to illustrate the usag...

Vue3 Documentation Quick Start

Table of contents 1. Setup 1. The first parameter...

Detailed explanation of the solution for migrating antd+react projects to vite

Antd+react+webpack is often the standard combinat...

Solution to the problem that the docker container cannot be stopped

The solution is as follows: 1. Force delete conta...

A simple LED digital clock implementation method in CSS3

This should be something that many people have do...

Detailed explanation of JQuery selector

Table of contents Basic selectors: Level selector...