Input loses focus and gets focus jquery Focus event plugin,
The text disappears when the mouse clicks in the search box .
When we do the site often use the search box to get focus and lose focus of the event, because lazy, every time to write very annoying, so once and for all, encounter similar situation to call on the OK
Related JS code:
1 2 3 <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
4 <title>input loses focus and gets focus jquery Focus Event Plugin-lazy people build station </title>
5 <script src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type= "Text/javascript" >< /script>
6 <script type= "Text/javascript" >
7 $ (document). Ready (function () {
8//focusblur
9 Jquery.focusblur = function (focusid) {
Ten var Focusblurid = $ (FOCUSID);
One-to-one var defval = Focusblurid.val ();
Focusblurid.focus (function () {
var Thisval = $ (this). Val ();
if (thisval==defval) {
$ (this). Val ("");
16}
17});
Focusblurid.blur (function () {
var Thisval = $ (this). Val ();
if (thisval== "") {
$ (this). Val (Defval);
22}
23});
24
25};
26/* The following is the calling method */
$.focusblur ("#searchkey");
28});
</script>
31
<body>
<form action= "" method= "POST" >
<input name= "" type= "text" value= "Enter search keywords" id= "Searchkey"/>
<input name= "" type= "Submit" id= "searchbtn" value= "Search"/>
</form>
PNS <p>input loses focus and gets focus jquery Focus event plugin, <br/><strong style= "color: #F00" > Mouse click in the search box when the text disappears </ Strong>. </p>
38
</body>
Input loses focus and gets focus jquery Focus Event