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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


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


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.


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.

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.


  // OKで実行する処理
  function executeTask() {

  // Cancelで実行する処理
  function cancelTask() {


  function test1() {
    showConfirmDialog('Are you ready?', executeTask, cancelTask);

  function test2() {
    // Cancelで何もしない場合
    showConfirmDialog('Are you ready?', executeTask);

<p><input type="button" onclick="test1()" value="Test1" /></p>
<p><input type="button" onclick="test2()" value="Test2" /></p>





 * 確認ダイアログを表示します。
 * @param  {String} message ダイアログに表示するメッセージ
 * @param  {Function} [okFunction] OKボタンクリック時に実行される関数
 * @param  {Function} [cancelFunction] Cancelボタンクリック時に実行される関数
function showConfirmDialog(message, okFunction, cancelFunction) {
  // Dialogを破棄する関数
  var _destroyDialog = function(dialogElement) {
    dialogElement.dialog('destroy'); // ※destroyなので、closeイベントは発生しない
    dialogElement.remove(); // ※動的に生成された要素を削除する必要がある

  // Dialog要素(呼び出し毎に、動的に生成)
  var $dialog = $('<div></div>').text(message);

  // 各ボタンに対応する関数を宣言
  // ※Dialogを破棄後、コールバック関数を実行する
  var _funcOk     = function() { _destroyDialog($dialog); if (okFunction)     { okFunction();     } };
  var _funcCancel = function() { _destroyDialog($dialog); if (cancelFunction) { cancelFunction(); } };

    modal: true,
    title: '確認',

    // 「閉じる」の設定
    // ※Cancel時の処理を「閉じる」に仕込むことで、Cancelと「閉じる」を同一の挙動とする
    closeText: 'Cancel',
    closeOnEscape: true,
    close: _funcCancel,

    // 各ボタンの設定
    buttons: [
      { text: 'OK',     click: _funcOk },
      { text: 'Cancel', click: function() { $(this).dialog('close'); } } // Dialogのcloseのみ