css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


<div class="test">1980/10/7</div>
<div class="test">1990/09/08</div>
<div class="test">2000年8月9日</div>
<div class="test">2010年7月10日</div>
<div class="test">2019/06-11</div>

<p>例えばAKB チームBのメンバー表があったとして、こんな感じに使います。<br>各メンバーの誕生日がくれば自動で年齢が変わります<br>jQueryのage部分を参考に新たに判定式を入れれば、今日の日付からメンバーの今年の日付を比較して同じになれば誕生日表示みたいな事も可能です(未導入)</p>

<table class="member">
		<td><img src="https://48pedia.org/images/thumb/0/08/2018%E5%B9%B4AKB48%E3%83%97%E3%83%AD%E3%83%95%E3%82%A3%E3%83%BC%E3%83%AB_%E6%9F%8F%E6%9C%A8%E7%94%B1%E7%B4%80.jpg/50px-2018%E5%B9%B4AKB48%E3%83%97%E3%83%AD%E3%83%95%E3%82%A3%E3%83%BC%E3%83%AB_%E6%9F%8F%E6%9C%A8%E7%94%B1%E7%B4%80.jpg"></td>
		<td><rb>柏木由紀</rb><rt>かしわぎ ゆき</rt></td>
		<td><div class="test">1991年7月15日</div></td>
		<td><img src="https://48pedia.org/images/thumb/5/50/2018%E5%B9%B4AKB48%E3%83%97%E3%83%AD%E3%83%95%E3%82%A3%E3%83%BC%E3%83%AB_%E4%B9%85%E4%BF%9D%E6%80%9C%E9%9F%B3.jpg/50px-2018%E5%B9%B4AKB48%E3%83%97%E3%83%AD%E3%83%95%E3%82%A3%E3%83%BC%E3%83%AB_%E4%B9%85%E4%BF%9D%E6%80%9C%E9%9F%B3.jpg"></td>
		<td><rb>久保怜音</rb><rt>くぼ さとね</rt></td>
		<td><div class="test">2003年11月20日</div></td>
		<td><img src="https://48pedia.org/images/thumb/3/3e/2018%E5%B9%B4AKB48%E3%83%97%E3%83%AD%E3%83%95%E3%82%A3%E3%83%BC%E3%83%AB_%E9%AB%98%E6%A9%8B%E6%9C%B1%E9%87%8C.jpg/50px-2018%E5%B9%B4AKB48%E3%83%97%E3%83%AD%E3%83%95%E3%82%A3%E3%83%BC%E3%83%AB_%E9%AB%98%E6%A9%8B%E6%9C%B1%E9%87%8C.jpg"></td>
		<td><rb>高橋朱里</rb><rt>たかはし じゅり</rt></td>
		<td><div class="test">1997年10月3日</div></td>
		<td><img src="https://48pedia.org/images/thumb/9/92/2018%E5%B9%B4AKB48%E3%83%97%E3%83%AD%E3%83%95%E3%82%A3%E3%83%BC%E3%83%AB_%E7%A6%8F%E5%B2%A1%E8%81%96%E8%8F%9C.jpg/50px-2018%E5%B9%B4AKB48%E3%83%97%E3%83%AD%E3%83%95%E3%82%A3%E3%83%BC%E3%83%AB_%E7%A6%8F%E5%B2%A1%E8%81%96%E8%8F%9C.jpg"></td>
		<td><rb>福岡聖菜</rb><rt>ふくおか せいな</rt></td>
		<td><div class="test">2000年8月1日</div></td>

	<li class="test">柏木由紀<span class="ageOnly">1991年7月15日</span></li>
	<li class="test">久保怜音<span class="ageOnly">2003/11/20</span></li>
	<li class="test">高橋朱里<span class="ageOnly">1997年10月3日</span></li>
	<li class="test">福岡聖菜<span class="ageOnly">2000年8月1日</span></li>

	<li>2019/2/16 jQueryを少しだけ編集。関数化しただけで内用に変化なし</li>
	<li>2019/2/12 作成例2を追加、それに伴いjQuery側年齢の処理を追加</li>
	<li>2019/2/11 作成例追加、年齢の括弧部分・歳をcssに変更</li>

<p>参考サイト: <a href="https://qiita.com/clockmaker/items/865ceafae7117606169a" target="_blank">qiita: JavaScriptで生年月日から年齢を計算する簡単ロジック</a></p>
<p>参考サイト: <a href="https://48pedia.org/AKB48%E3%83%A1%E3%83%B3%E3%83%90%E3%83%BC%E4%B8%80%E8%A6%A7" target="_blank">エケペディア AKBメンバー一覧</a></p>
              .age {
	color: #669;
.age::after {
	margin-left: 4px;
	margin-right: 4px;
.age::before {
	content: "(";
.age::after {
	content: "歳 )";
	margin-left: 0px;

.member {
	border: 0;
	border-collapse: collapse;
	font-family: sans-serif;
.member tr td{
	padding: 2px 16px;
.member tr td:nth-of-type(2) {
	font-size: 20px;
.member tr td:nth-of-type(4) {
	text-align: center;
.member tr td:nth-of-type(5) {
	text-align: center;
.member tr:nth-of-type(even) {
	background-color: #efefef;
              (function($) {
	const t = "test";

	const c = $("." + t);
	const today = new Date();
	let birth, txt, b, bd, y, m, d, y1, y2, m1, m2, d1, d2, age;

	const f_birth = (y, m, d) => {
		bd = new Date(y, m, d);

		y2 = bd
			.padStart(4, "0");
		m2 = (bd.getMonth() + 1).toString().padStart(2, "0");
		d2 = bd
			.padStart(2, "0");

		y1 = today
			.padStart(4, "0");
		m1 = (today.getMonth() + 1).toString().padStart(2, "0");
		d1 = today
			.padStart(2, "0");

		age = Math.floor((Number(y1 + m1 + d1) - Number(y2 + m2 + d2)) / 10000);
		return age;

	c.each(function(i) {
		txt = $(this).text();

		b = txt.match(/(\d{1,4})/g);

		birth = {
			year: b[0],
			month: b[1],
			day: b[2]

		const ages = f_birth(birth.year, birth.month - 1, birth.day);


		if (
		) {
			const bday = $(this)
			$(this).append("<span class='age' title='" + bday + "'>" + age + "</span>");
		} else {
			$(this).append("<span class='age'>" + age + "</span>");

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................