Jquery to achieve non superposition search box prompt effect

  • 2020-03-30 01:15:01
  • OfStack

In the past, JQUERY has been used to superimpose two INPUT boxes to realize the user name and password that need to be INPUT in login to achieve prompt and user output. Here, JQUERY is used to achieve this effect in an INPUT box. The specific method is as follows:

Here is the code for the INPUT box:
 
<input class="search_text" type="text" value=" search " name="searchText" /> 

Here's the JQUERY code:
 
//Set the default value for the search
$(".search_text").focus(function(){ 
<span style="white-space:pre"> </span>if($(".search_text").val()==' search '){ 
<span style="white-space:pre"> </span>$(".search_text").val(""); 
<span style="white-space:pre"> </span>}else{ 
<span style="white-space:pre"> </span>$(".search_text").val($(".search_text").val()); 
<span style="white-space:pre"> </span>} 
}); 
$(".search_text").blur(function(){ 
<span style="white-space:pre"> </span>if($(".search_text").val()==''){ 
<span style="white-space:pre"> </span>$(".search_text").val(" search "); 
<span style="white-space:pre"> </span>}else{ 
<span style="white-space:pre"> </span>$(".search_text").val($(".search_text").val()); 
<span style="white-space:pre"> </span>} 
}); 

Format what I do not adjust, after all, is not the use of programming IDE editor, interested, you can look at the next yo!

Related articles: