Skip to content

Instantly share code, notes, and snippets.

@shingorow
Created February 27, 2017 12:07
Show Gist options
  • Save shingorow/e2e5f92a5916f1ec998ce4a199e7d256 to your computer and use it in GitHub Desktop.
Save shingorow/e2e5f92a5916f1ec998ce4a199e7d256 to your computer and use it in GitHub Desktop.
任意のクラスを持つ input タグの値に今日の日付をセットする
(function(global) {
function SetValueToToday(className) {
var date = new Date(),
year,
month,
day,
today;
this.className = className || 'set-value-to-today';
this.className = this.className.replace(/^\./, '');
year = date.getFullYear();
month = date.getMonth() + 1;
day = date.getDate();
today = year + '/' + month + '/' + day;
$('.' + this.className).val(today);
}
global.SetValueToToday = SetValueToToday;
}(this));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment