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.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.


                <!--Refer from
<form name='form' id='form'>
  <input type='text' name='name' id='name' /> 
  <input type='text' name='email' id='email' />
  <input type='button' value='送出' data-action="submit"/>




                const submitBtn = document.querySelector('[data-action="submit"]');
submitBtn.addEventListener("click", processFormData);

function processFormData(e) {
  // 方法 1-1:getElementById - 從 input
  // const nameElement = document.getElementById("name");
  // const name = nameElement.value;
  // const emailElement = document.getElementById("email");
  // const email = emailElement.value;

  // 方法 1-2:getElementById - 從 form
  // const formElement = document.getElementById("form");
  // const name = formElement[0].value;
  // const email = formElement[1].value;


  // 方法 2:getElementsByTagName
  // const inputElement = document.getElementsByTagName('input');
  // const name = inputElement[0].value;
  // const email = inputElement[1].value;

  // 方法 3:getElementsByName
  // const nameElement = document.getElementsByName('name');
  // const name = nameElement[0].value;
  // const emailElement = document.getElementsByName('email');
  // const email = emailElement[0].value;

  // 方法 4:取得表單元素
  //取得 name 屬性為 form 的表單
  const form = document.forms['form'];
  //取 elements 集合中 name 屬性為 name 的值
  const name =;
  //取 elements 集合中 name 屬性為 email 的值
  const email =;

  alert("你的姓名是 " + name + "\n電子郵件是 " + email);