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="m-3">
<a href="#" class="btn btn-success" id="deleteUserButton">削除ボタン</a> 
</div>

<div class="m-3">
  <a href="#" class="btn btn-info" id="infoButton">情報ボタン</a>
</div>

<div class="m-3">
  <a href="#" class="btn btn-warning" id="abortButton">中断ボタン</a>
</div>

<div class="m-3">
  <span id="output"></span>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                (function (ns) {

    // Sweet Alert 2が読み込まれてなければ抜ける
    if (typeof Swal === "undefined") {
        console.error("プラグイン「SweetAlert2」が読み込まれていません。先にscriptタグで読み込んでください");
        return false;
    }
  
   var AlertMessage = function () {

        // 既存のインスタンスの有無をチェック
        if (typeof AlertMessage.instance === "object") {
            return AlertMessage.instance;
        }

        // キャッシュ
        AlertMessage.instance = this;
        return this;
    };

    /**
     * Swalそのものを使ってアラート表示
     * @param msg_o object Swal参照
     */
    AlertMessage.prototype.show = function (msg_o) {
        Swal.fire(msg_o);
    }

    /**
     * confirmラッパー
     * @param _text String 表示したい内容テキスト
     * @param _title String 表示したいタイトルテキスト
     * @param _mode string アラートの種類 bootstrapと同じ or 'question' ( ?マーク )
     * @param _callback function アラートの結果を受けて関数を呼び出す。引数に成否を渡す
     * @param _array [] コールバックに渡したいもの配列
     * @constructor
     */
    AlertMessage.prototype.confirm = function (_text, _title, _mode, _callback,_array) {

        var dispTitle = _title;
        if (typeof dispTitle === "undefined") {
            dispTitle = "確認";
        }

        var o = {
            allowOutSideClick: false,
            showCancelButton: true,
            confirmButtonText: 'OK',
            cancelButtonText: "キャンセル",
            customClass: {
                cancelButton: 'btn btn-gray', //bootstrap4のクラス
            },
            title: dispTitle,
            html: _text
        };

        if (_mode === "success" ||
            _mode === "error" ||
            _mode === "warning" ||
            _mode === "info" ||
            _mode === "question") {
            o["type"] = _mode;
        };

        Swal.fire(o).then(function (result) {
            var retBool = false;
            if (typeof result.value !== "undefined" && result.value === true) {
                retBool = true;
            }
            if(typeof _callback === "function"){
                _callback.call(this, retBool,_array);
            }
        });

    };

    /**
     * Alertラッパー
     * @param _text String 表示したい内容テキスト
     * @param _title String 表示したいタイトルテキスト
     * @param _mode string アラートの種類 bootstrapと同じ or 'question' ( ?マーク )
     * @constructor
     */
    AlertMessage.prototype.alert = function (_text, _title, _mode) {

        var o = {
            allowOutSideClick: false,
            type: _mode,
            title: _title,
            html: _text
        }
        Swal.fire(o);
    };

    ns.AlertMessage = new AlertMessage();

})(window);

$(function(){
  
  // 削除ボタン処理
  $(document).on("click", "#deleteUserButton", function (e) {
      e.preventDefault(); // 本来のボタン押下の処理のキャンセル
      
      AlertMessage.confirm(
          "ユーザーのデータを削除します。よろしいですか?", // confirm本文
          "ユーザーの削除の確認", // confirmタイトル
          "info", // アラートの種類
          function (_enter) { // コールバック
            if (_enter) {
              // OKが押された時の処理
              $("#output").html("削除されました。");
            }
          });
    });
  
   // 削除ボタン処理
  $(document).on("click", "#infoButton", function (e) {
      e.preventDefault(); // 本来のボタン押下の処理のキャンセル
    
      var infoArray = ["タンタン", "パンダ", "神戸"];
    
      AlertMessage.confirm(
          "情報を追加してもよろしいですか?", // confirm本文
          "確認", // confirmタイトル
          "question", // アラートの種類
          function (_enter, _array) { // コールバック
            if (_enter) {
              // OKが押された時の処理
              var _text = "";
              $(_array).each(function(i){
                _text += this;
                if(i < _array.length -1){
                _text += ",";
                }
              });
              $("#output").html(_text);
            }
          },infoArray);
    });
   // 削除ボタン処理
  $(document).on("click", "#abortButton", function (e) {
      e.preventDefault(); // 本来のボタン押下の処理のキャンセル
  AlertMessage.alert(
          "処理を中断します。", // alert本文
          "エラー!", // alertタイトル
          "warning", // アラートの種類
         );
  });
});
              
            
!
999px

Console