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 id="table">
  <input type="search" class="search" placeholder="検索" />
  <input type="checkbox" id="men" checked>男
  <input type="checkbox" id="women" checked>女
  <table>
    <thead>
      <tr>
        <th class="sort" data-sort="name">名前</th>
        <th class="sort" data-sort="age">年齢</th>
        <th class="sort" data-sort="place">出身</th>
        <th class="sort" data-sort="sex">性別</th>
      </tr>
    </thead>
    <tbody class="list">
      <tr>
        <td class="name">田中</td>
        <td class="age">24</td>
        <td class="place">福岡</td>
        <td class="sex">男</td>
      </tr>
      <tr>
        <td class="name">鈴木</td>
        <td class="age">22</td>
        <td class="place">熊本</td>
        <td class="sex">男</td>
      </tr>
      <tr>
        <td class="name">佐藤</td>
        <td class="age">30</td>
        <td class="place">鹿児島</td>
        <td class="sex">女</td>
      </tr>
      <tr>
        <td class="name">高橋</td>
        <td class="age">27</td>
        <td class="place">宮崎</td>
        <td class="sex">男</td>
      </tr>
      <tr>
        <td class="name">伊藤</td>
        <td class="age">33</td>
        <td class="place">大分</td>
        <td class="sex">男</td>
      </tr>
      <tr>
        <td class="name">渡辺</td>
        <td class="age">24</td>
        <td class="place">佐賀</td>
        <td class="sex">女</td>
      </tr>
      <tr>
        <td class="name">中村</td>
        <td class="age">29</td>
        <td class="place">長崎</td>
        <td class="sex">女</td>
      </tr>
      <tr>
        <td class="name">山本</td>
        <td class="age">25</td>
        <td class="place">熊本</td>
        <td class="sex">男</td>
      </tr>
      <tr>
        <td class="name">青木</td>
        <td class="age">30</td>
        <td class="place">宮崎</td>
        <td class="sex">女</td>
      </tr>
      <tr>
        <td class="name">村上</td>
        <td class="age">24</td>
        <td class="place">熊本</td>
        <td class="sex">男</td>
      </tr>
      <tr>
        <td class="name">山田</td>
        <td class="age">31</td>
        <td class="place">鹿児島</td>
        <td class="sex">男</td>
      </tr>
    </tbody>
  </table>
  <div class="pager">
    <ul class="pagination"></ul>
  </div>
</div>
              
            
!

CSS

              
                /* 並び替え */
th.sort {
  cursor: pointer;
}

th.sort.desc:after {
  content: "▼";
  margin-left: 8px;
  font-size: 14px;
}

th.sort.asc:after {
  content: "▲";
  margin-left: 8px;
  font-size: 14px;
}

/* ページネーション */
.pager ul {
    list-style: none;
    position: relative;
    left: 50%;
    float: left;
}

.pager ul li {
    margin: 0 5px;
    position: relative;
    left: -50%;
    float: left;
}

.pager ul li span,
.pager ul li a {
    display: block;
    padding: 8px 15px;
    border-radius: 5px;
}

.pager ul li a {
    background-color: #EEE;
    color: #000;
    text-decoration: none;
}

.pager ul li a:hover,
.pager ul li.active a:hover {
    background-color: #333;
    color: #FFF;
}

.pager ul li.active a {
    font-weight: bold;
    background-color: #ccc;
}

/* 検索 */
input[type="search"] {
  margin: 20px 0;
}

/* テーブル */
div#table {
  margin: 0 auto;
  width: 450px;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  border: 1px solid #000;
}

table th,
table td {
  border: 1px solid #000;
}
              
            
!

JS

              
                /**
 * List.js用のオプション設定
 */
var options = {
  // 並び替え項目
  valueNames: [ 'name', 'age', 'place', 'sex' ],
  // 1ページに表示するデータ数
  page: 3,
  // ページネーション
  pagination: {
    paginationClass:'pagination',
    innerWindow:1,
    outerWindow:1,
  },
};

/**
 * List.jsのインスタンス生成
 */
var userList = new List('table', options);

/**
 * フィルター処理
 */
function filter() {
  // List.jsのフィルタリング
  userList.filter(
    function(item) {
      
      // 男のチェックボックスにチェックがついていて、データが男の場合
      if (sex_men.checked && item.values()['sex'] == '男') {
        // 表示する
        return true;
      }
      // 女のチェックボックスにチェックがついていて、データが女の場合
      else if (sex_women.checked && item.values()['sex'] == '女') {
        // 表示する
        return true;
      }
      // 上記以外の場合
      else {
        // 表示しない
        return false;
      }
    }
  );
}

/**
 * 男のチェックボックス
 */
var sex_men = document.getElementById("men");
sex_men.addEventListener('change', filter);

/**
 * 女のチェックボックス
 */
var sex_women = document.getElementById("women");
sex_women.addEventListener('change', filter);

// フィルター処理
filter();
              
            
!
999px

Console