2022-07-18 16:29:02 +00:00
|
|
|
|
---
|
|
|
|
|
id: 60f81167d0d4910809f88945
|
2022-09-28 14:09:47 +00:00
|
|
|
|
title: 步驟 19
|
2022-07-18 16:29:02 +00:00
|
|
|
|
challengeType: 0
|
2022-09-28 14:09:47 +00:00
|
|
|
|
dashedName: step-19
|
2022-07-18 16:29:02 +00:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# --description--
|
|
|
|
|
|
|
|
|
|
距離父級 `form` 元素最近的第一個 `type` 爲 `submit` 的 `input` 元素會被當作提交按鈕。
|
|
|
|
|
|
|
|
|
|
爲了處理表單提交,在最後 `fieldset` 元素後添加一個 `input` 元素,其 `type` 屬性設置爲 `submit`,`value` 屬性設置爲 `Submit`。
|
|
|
|
|
|
|
|
|
|
# --hints--
|
|
|
|
|
|
|
|
|
|
應該將 `input` 元素添加到最後一個 `fieldset` 元素後。
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
assert.exists(document.querySelectorAll('fieldset')?.[2]?.nextElementSibling?.tagName, 'input');
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
`input` 的 `type` 屬性值應該爲 `submit`。
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
assert.exists(document.querySelector('fieldset + input[type="submit"]'));
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
`input` 元素的 `value` 屬性值應該爲 `Submit`。
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
assert.exists(document.querySelector('fieldset + input[value="Submit"]'));
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# --seed--
|
|
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
|
|
```html
|
|
|
|
|
<!DOCTYPE html>
|
2022-09-28 14:09:47 +00:00
|
|
|
|
<html lang="en">
|
2022-07-18 16:29:02 +00:00
|
|
|
|
<head>
|
2022-09-28 14:09:47 +00:00
|
|
|
|
<meta charset="UTF-8">
|
2022-07-18 16:29:02 +00:00
|
|
|
|
<title>Registration Form</title>
|
2022-09-28 14:09:47 +00:00
|
|
|
|
<link rel="stylesheet" href="styles.css" />
|
2022-07-18 16:29:02 +00:00
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<h1>Registration Form</h1>
|
|
|
|
|
<p>Please fill out this form with the required information</p>
|
|
|
|
|
<form action='https://register-demo.freecodecamp.org'>
|
|
|
|
|
--fcc-editable-region--
|
|
|
|
|
<fieldset>
|
2022-09-28 14:09:47 +00:00
|
|
|
|
<label for="first-name">Enter Your First Name: <input id="first-name" type="text" /></label>
|
|
|
|
|
<label for="last-name">Enter Your Last Name: <input id="last-name" type="text" /></label>
|
|
|
|
|
<label for="email">Enter Your Email: <input id="email" type="email" /></label>
|
|
|
|
|
<label for="new-password">Create a New Password: <input id="new-password" type="password" /></label>
|
2022-07-18 16:29:02 +00:00
|
|
|
|
</fieldset>
|
|
|
|
|
<fieldset></fieldset>
|
|
|
|
|
<fieldset></fieldset>
|
|
|
|
|
|
|
|
|
|
--fcc-editable-region--
|
|
|
|
|
</form>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```css
|
|
|
|
|
body {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
margin: 0;
|
|
|
|
|
background-color: #1b1b32;
|
2022-09-28 14:09:47 +00:00
|
|
|
|
color: #f5f6f7;
|
2022-07-18 16:29:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
label {
|
2022-09-28 14:09:47 +00:00
|
|
|
|
display: block;
|
|
|
|
|
margin: 0.5rem 0;
|
2022-07-18 16:29:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
```
|