Last active
December 2, 2017 23:51
-
-
Save osbulbul/4745060 to your computer and use it in GitHub Desktop.
[Placeholder Example] English : After you load your jquery file paste this code in to your scripts file and you can use with $(".clear").clearAll(); ---- and the new function clear all inputs which have clear class for you. Also if users leave blank your inputs function automatically give the first value.|||||||||||||||||||||||Turkish : Jquery d…
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
$.fn.clearAll = function() { | |
this.each(function(){ | |
var $this = $(this); | |
var resultText = ''; | |
var oldText = $this.val(); | |
$this.on('focus',function(){ | |
resultText = ($this.val() === oldText) ? '' : $this.val(); | |
$this.val(resultText); | |
}); | |
$this.on('blur',function(){ | |
resultText = ($this.val() === '') ? oldText : $this.val(); | |
$this.val(resultText); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment