jquery method to achieve common effects of search box_jquery
May 16, 2016 pm 04:18 PMThe example in this article describes how jquery implements common effects of the search box. Share it with everyone for your reference. The specific implementation method is as follows:
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>jquery search box effect</title>
<script type="text/javascript" src="jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(function(){
var searchBox = $("#search");
searchBox.focus(function(){
If(searchBox.val() == this.title){
SearchBox.val("").css({'font-style':'normal','color':'#000'});
}
});
//When the cursor leaves the search box
searchBox.blur(function(){
If(searchBox.val() == ""){
SearchBox.val(this.title).css({'font-style':'italic','color':'#ccc'});
}
});
searchBox.blur();
});
</script>
</head>
<body>
<input id="search" type="text" title="search" value="" /><input type="submit" value="Search" />
</body>
</html>
I hope this article will be helpful to everyone’s jQuery programming.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Users encounter rare glitches: Samsung Watch smartwatches suddenly experience white screen issues

How to write a novel in the Tomato Free Novel app. Share the tutorial on how to write a novel in Tomato Novel.

How to recover deleted contacts on WeChat (simple tutorial tells you how to recover deleted contacts)

Quickly master: How to open two WeChat accounts on Huawei mobile phones revealed!

The secret of hatching mobile dragon eggs is revealed (step by step to teach you how to successfully hatch mobile dragon eggs)

Kyushu Fengshen Assassin 4S Radiator Review Air-cooled 'Assassin Master' Style

How to set font size on mobile phone (easily adjust font size on mobile phone)

The difference between Go language methods and functions and analysis of application scenarios
