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

              
                <form name="contact_form">
  <p>
    <label for="subject">件名:</label><input type="text" id="subject" name="subject" value="昨日の依頼について">
  </p>
  <button type="button" name="clear">クリア</button>
</form>
<p>
  <a id="tec_link" href="https://techacademy.jp/" target="_blank">テックアカデミーのサイトを開く</a>
</p>
              
            
!

CSS

              
                
              
            
!

JS

              
                //*************************************************
// 文字をクリアする確認
//*************************************************

//クリアボタンの取得
const button = contact_form.clear;
//クリアボタンが押されたときの処理を定義
button.addEventListener('click', () => {
  //input要素(name属性がsubject)の入力内容を取得
  const text = contact_form.subject.value;

  //入力内容の確認
  const isOk = confirm('以下の件名を削除しますか?\n' + text);

  //「OK」が押されたか
  if(isOk){
    //件名の入力内容をクリア
    contact_form.subject.value ="";
  }
});


//*************************************************
// リンクを開く確認
//*************************************************

//リンクがあるアンカーの取得
const anchor = document.getElementById('tec_link');
//リンクがクリックされたときの処理
anchor.addEventListener('click', (event) => {
  //確認ダイアログの表示
  const isOk = confirm('以下のサイトを表示しますか?\n' + event.target.href);

  //「キャンセル」が押されたか
  if(!isOk){
    //デフォルトの動作(リンクの遷移)を停止
    event.preventDefault();
  }
});
              
            
!
999px

Console