<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
<Script type = "text/javascript" src = "js/jquery-1.4.2.min.js"> </script>
<Script type = "text/javascript">
// Method 1
$ (Document). ready (function (){
Var doc = document, inputs = doc. getElementsByTagName ('input'), supportPlaceholder = 'placeholder' in doc. createElement ('input'), placeholder = function (input) {var text = input. getAttribute ('placeholder '), defaultValue = input. defaultValue;
If (defaultValue = ''){
Input. value = text}
Input. onfocus = function (){
If (input. value = text) {this. value = ''}};
Input. onblur = function () {if (input. value = '') {this. value = text }}};
If (! SupportPlaceholder ){
For (var I = 0, len = inputs. length; I <len; I ++) {var input = inputs [I], text = input. getAttribute ('placeholder ');
If (input. type = 'text' & text) {placeholder (input )}}}});
// Method 2
$ (Function (){
If (! PlaceholderSupport () {// determines whether the browser supports placeholder
$ ('[Placeholder]'). focus (function (){
Var input = $ (this );
If (input. val () = input. attr ('placeholder ')){
Input. val ('');
Input. removeClass ('holder ');
}
}). Blur (function (){
Var input = $ (this );
If (input. val () = ''| input. val () = input. attr ('placeholder ')){
Input. addClass ('holder ');
Input. val (input. attr ('holder '));
}
}). Blur ();
};
})
Function placeholderSupport (){
Return 'placeholder' in document. createElement ('input ');
}
</Script>
</Head>
<Body>
<Form>
<Label for = "name"> User name: </label>
<Input type = "text" placeholder = "Enter the user name"/>
</Form>
</Body>
</Html>