Skip to content

Latest commit

 

History

History
36 lines (30 loc) · 1.02 KB

JavaScriptDOM.md

File metadata and controls

36 lines (30 loc) · 1.02 KB

DOM

Всплытие и погружение

Обработка пользовательских событий

Обработка данных формы

<form name="valform" onsubmit="handleSubmit(event)">
  Name: <input type="text" name="name">
  <br/>
  Card Type:
  <select name="cardType">
    <option value="visa">Visa</option>
    <option value="mastercard">MasterCard</option>
    <option value="discover">Discover</option>
    <option value="amex">Amex</option>
    <option value="diners">Diners Club</option>
  </select>
  <br/>
  <button type="submit">Submit</button>
</form>
function handleSubmit(e) {
  e.preventDefault();
  const formData = new FormData(e.target);
  const values = Object.fromEntries(formData);
  console.log(values); // { name: '...', cardType: '...' }
}

image image