html - Populate fields with default values using Jquery -


I would like to use jquery to populate fields with default values ​​For example, I have an email address Field and I want to add example@email.com to the gray italic text in the box and delete the user when the user clicks on the field. Is there any good way to do this with a plugin or something? If possible I would really like to toggle a fully deployed division.

  & lt; Input type = "text" id = "email" /> & Lt; Input type = "text" id = "name" />  

Then,

  $ (function () {$ ('# email'). Focus (focus). Blur [0] Focus (Focus) Blur (Blur) [0] .defaultValue = "Type name here";}) Function Focus () {this.value = (This.value == this.defaultValue)? '': This.value; } Function Blur () {this.value = (this.value == '')? This.defaultValue: this.value; } $ (Function () {$ ('# email, # name') with AddClass ('default').  

with styles

 Focus: Blur [0] .defaultValue = "example@email.com"; $ ('# name') Focus (focus). Blur [Blur] [0] .defaultValue = "Type name here";}); Function Focus () {If (this.value == this.defaultValue) {this.value = ''; $ (This) .removeClass ('default'); }} Work stain () {if (this.value == '') {this.value = this.defaultValue; $ (This) .addClass ('default'); }}  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -