Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="table-filters">
	<select id="filter">
		<option disabled selected value="none">Select a genre</option>
		<option>Hip Hop</option>
		<option>Jazz</option>
		<option>Soul</option>
		<option>R&B</option>
	</select>
</div>

<table>
	<thead>
		<tr>
			<th>Album title</th>
			<th>Artist</th>
			<th>Genre</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>Illmatic</td>
			<td>Nas</td>
			<td>Hip Hop</td>
		</tr>
		<tr>
			<td>Beyoncé</td>
			<td>Lemonade</td>
			<td>R&B</td>
		</tr>
		<tr>
			<td>Marvin Gaye</td>
			<td>Let's Get It On</td>
			<td>Soul</td>
		</tr>
		<tr>
			<td>Bitches Brew</td>
			<td>Miles Davis</td>
			<td>Jazz</td>
		</tr>
		<tr>
			<td>Channel Orange</td>
			<td>Frank Ocean</td>
			<td>R&B</td>
		</tr>
		<tr>
			<td>Midnight Marauders</td>
			<td>A Tribe Called Quest</td>
			<td>Hip Hop</td>
		</tr>
		<tr>
			<td>Oxnard</td>
			<td>Anderson Paak</td>
			<td>R&B</td>
		</tr>
		<tr>
			<td>Talking Book</td>
			<td>Stevie Wonder</td>
			<td>Soul</td>
		</tr>
		<tr>
			<td>A Love Supreme</td>
			<td>John Coltrane</td>
			<td>Jazz</td>
		</tr>
		<tr>
			<td>Lady Soul</td>
			<td>Aretha Franklin</td>
			<td>Soul</td>
		</tr>
	</tbody>
</table>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Be+Vietnam:400,500&display=swap');

*, ::after, ::before {
	box-sizing: border-box;
}

body {
	background: #EEF9F0;
	font-family: 'Be Vietnam', sans-serif;
	font-size: 15px;
	font-weight: 400;
	line-height: 1.4;
	padding: 2em;
}

.table-filters {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 2em;
	
	a {
		color: #222;
		font-size: 16px;
		font-weight: 500;
		margin-right: 1em;
		display: inline-block;
		
		&:hover {
			text-decoration: none;
		}
	}
	
	select {
		background: #fff;
		font-family: 'Be Vietnam', sans-serif;
		font-size: 16px;
		font-weight: 500;
		width: 12em;
		height: 2.5em;
	}
}

table {
	background: #fff;
	width: 100%;
	table-layout: fixed;
	border-radius: 6px;
}

thead {
	background: #1A5DC8;
	color: #fff;
}

th {
	font-size: 16px;
	font-weight: 500;
	text-align: left;
	padding: 1em;
	border-bottom: 1px solid #ddd;
}

tbody td {
	padding: 1.5em 1em;
}

tbody tr {
	
	&.show {
		display: table-row;
	}
	
	&.hidden {
		display: none;
	}
	
	&.bg-grey,
	&:nth-child(odd){
		background: #f1f1f1;
	}
	
	&:last-child td {
		border-bottom: none;
	}
}

/* Media queries */
@media(min-width: 520px) {
	body {
		padding: 3em;
	}
}
              
            
!

JS

              
                // Highlight odd rows
highlightRows = () => {
	let oddRows = document.querySelectorAll('tbody tr.show')
	oddRows.forEach((row, index)=> {
		if (index % 2 == 0) {
			row.style.background = '#f1f1f1'
		} else {
			row.style.background = '#fff'
		}
	})
}

// Filter table based on select
const filterOptions = () => {
	const option = document.querySelector("#filter").value;
	const selection = option.replace('&', '')
	const rows = document.querySelectorAll("tbody tr");
	
	rows.forEach(row => {
		let td = row.querySelector("td:last-child");
		let filter = td.innerText.replace('&', '');
		if (filter === selection) {
			row.className = 'show'
		} else {
			row.className = 'hidden'
		}
	});
	highlightRows()
};
document.getElementById("filter").addEventListener("change", filterOptions);
              
            
!
999px

Console