Skip to content

Instantly share code, notes, and snippets.

@osbulbul
Last active December 2, 2017 23:51
Show Gist options
  • Save osbulbul/4745060 to your computer and use it in GitHub Desktop.
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…
$.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