Last active
December 23, 2015 19:09
-
-
Save dribble13/6680677 to your computer and use it in GitHub Desktop.
ブラウザ側で日時指定で表示・非表示を切り替えるスクリプト ref: http://qiita.com/dribble13/items/3eb39726aba33add6c0a
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
$(document).ready(function() { | |
$(".view_timer").each(function(index, target) { | |
var startDate = $(this).attr("start_date"); | |
var endDate = $(this).attr("end_date"); | |
var nowDate = new Date(); | |
if (startDate) { | |
startDate = new Date(startDate); | |
} | |
else { | |
startDate = nowDate; | |
} | |
if (endDate) { | |
endDate = new Date(endDate); | |
} | |
if (startDate <= nowDate && (!endDate || nowDate <= endDate)) { | |
$(this).show(); | |
} | |
else { | |
$(this).hide(); | |
} | |
}); | |
}); |
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
<span class="view_timer" start_date="2013/9/24 10:00" end_date="2013/9/30 21:00">HogeHogeFugaFuga</span> |
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
<span class="view_timer" start_date="2013/9/24 10:00">テスト</span> |
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
<span class="view_timer" end_date="2013/9/30 21:00">お試し</span> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment