Created
June 3, 2017 05:10
-
-
Save DevShahidul/5638d6468488ceeb085ef40fc9f9222c to your computer and use it in GitHub Desktop.
This function for input active state on focus with value added and value removed state.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Begin input common focus and blur for value. | |
$('input:text,input:password,textarea').focus(function(){ | |
if(this.value==this.defaultValue){ | |
this.value=''; | |
} | |
}) | |
$('input:text,input:password,textarea').blur(function(){ | |
if(!this.value){this.value=this.defaultValue;} | |
if(this.value==this.defaultValue){ | |
$(this).removeClass('value-added') | |
} | |
else{ | |
$(this).addClass('value-added') | |
} | |
}) | |
// Ends input common focus and blur for value. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment