JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
<section class="container">
<input type="search" class="light-table-filter" data-table="order-table" placeholder="検索" />
<table class="order-table">
<thead>
<tr>
<th>名前</th>
<th>職業</th>
<th>住所</th>
<th>年齢</th>
</tr>
</thead>
<tbody>
<tr>
<td>はなこ</td>
<td>医師(いし)</td>
<td>新潟県(にいがた)</td>
<td>38</td>
</tr>
<tr>
<td>たけし</td>
<td>海洋研究(かいようけんきゅう)</td>
<td>岡山県(おかやま)</td>
<td>48</td>
</tr>
<tr>
<td>えり</td>
<td>AI開発(えーあいかいはつ)</td>
<td>徳島県(とくしま)</td>
<td>25</td>
</tr>
<tr>
<td>けんじ</td>
<td>大学教授(だいがくきょうじゅ)</td>
<td>長崎県(ながさき)</td>
<td>61</td>
</tr>
<tr>
<td>あきお</td>
<td>俳優(はいゆう)</td>
<td>山口県(やまぐち)</td>
<td>33</td>
</tr>
<tr>
<td>みなこ</td>
<td>刑事(けいじ)</td>
<td>鳥取県(とっとり)</td>
<td>41</td>
</tr>
<tr>
<td>まみ</td>
<td>学生(がくせい)</td>
<td>福島県(ふくしま)</td>
<td>18</td>
</tr>
</tbody>
</table>
</section>
.container {
text-align: center;
overflow: hidden;
width: 600px;
margin: 0 auto;
}
.container table {
width: 100%;
}
.container td, .container th {
padding: 10px;
}
.container td:first-child, .container th:first-child {
padding-left: 20px;
}
.container td:last-child, .container th:last-child {
padding-right: 20px;
}
.container th {
border-bottom: 1px solid #ddd;
position: relative;
}
(function(document) {
'use strict';
var LightTableFilter = (function(Arr) {
var _input;
function _onInputEvent(e) {
_input = e.target;
var tables = document.getElementsByClassName(_input.getAttribute('data-table'));
Arr.forEach.call(tables, function(table) {
Arr.forEach.call(table.tBodies, function(tbody) {
Arr.forEach.call(tbody.rows, _filter);
});
});
}
function _filter(row) {
var text = row.textContent.toLowerCase(), val = _input.value.toLowerCase();
row.style.display = text.indexOf(val) === -1 ? 'none' : 'table-row';
}
return {
init: function() {
var inputs = document.getElementsByClassName('light-table-filter');
Arr.forEach.call(inputs, function(input) {
input.oninput = _onInputEvent;
});
}
};
})(Array.prototype);
document.addEventListener('readystatechange', function() {
if (document.readyState === 'complete') {
LightTableFilter.init();
}
});
})(document);
Also see: Tab Triggers