cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

                  <ul id="js-item-list" class="item-list">

    <textarea id="js-console"></textarea>

    <ul id="js-item-template" class="ui-helper-hidden">
      <li data-item-cd="" class="item">
        <div class="ui-helper-clearfix">
          <div class="item-title">
            <span class="js-item-name">アイテム名</span>
            <input type="text" class="js-item-old-sort-no" value="1" />
            <input type="text" class="js-item-sort-no" value="1" />
          <a href="#" class="js-sort-handle sort-handle"><span class="ui-icon ui-icon-arrowthick-2-n-s" aria-hidden="true"></span><span></span></a>

              .item-list {
  width: 500px;
  list-style-type: none;
  margin: 0;
  padding: 0;

.item-list .item {
  border: 1px solid #eee;
  margin: 0 0 3px 0;
  padding: 5px;
  background-color: #efe;

.item-list .item .item-title {
  float: left;

.item-list .item .sort-handle {
  float: right;

#js-console {
  position: fixed;
  bottom: 0px;
  left: 0px;
  width: 100%;
  height: 100px;
              $(function() {
    var itemListBlock = $('#js-item-list');
    var itemTemplateBlock = $('#js-item-template');
    var consoleBlock = $('#js-console');

    var items = [
        {code: 'cd01', name: 'item1', sort_no: 1},
        {code: 'cd02', name: 'item2', sort_no: 2},
        {code: 'cd03', name: 'item3', sort_no: 3},
        {code: 'cd04', name: 'item4', sort_no: 4},
        {code: 'cd05', name: 'item5', sort_no: 5},
        {code: 'cd06', name: 'item6', sort_no: 6}, 
        {code: 'cd07', name: 'item7', sort_no: 7}, 
        {code: 'cd08', name: 'item8', sort_no: 8}, 
        {code: 'cd09', name: 'item9', sort_no: 9}, 
        {code: 'cd10', name: 'item10', sort_no: 12} 

    var addLog = function (message) {
        consoleBlock.val(message + '\n' + consoleBlock.val());

    var reOrderSortNo = function () {
        var sortNoList = $.map(items, function (item, i) {
            return item.sort_no;
        sortNoList.sort(function (a, b) {
            var numA = a - 0;
            var numB = b - 0;
            if (numA < numB) return -1; 
            if (numA > numB) return 1;
            return 0;

        $('li', itemListBlock).each(function (i) {
            var itemBlock = $(this);
            $('.js-item-sort-no', itemBlock).val(sortNoList[i]);
    $.each(items, function (i, item) {
        var itemBlock = $('li', itemTemplateBlock).clone();
        itemBlock.attr('data-item-cd', item.code);
        $('.js-item-name', itemBlock).text(item.name);
        $('.js-item-old-sort-no', itemBlock).val(item.sort_no);
        $('.js-item-sort-no', itemBlock).val(item.sort_no);

        handle: '.js-sort-handle',
        update: function (e, ui) {
            var targetItemCd = ui.item.attr('data-item-cd');
            addLog('item ' + targetItemCd + ' position updated');


Loading ..................