JS第二課作業
基本的變數操作、從 html 取得內容
by igorrrrr
HTML
<div class="wrap">
<h1>線上下單</h1>
<section>
<div class="memberName">
<label for="memberName">客戶名稱:</label>
<input id="memberName" text="text" />
</div>
<div class="buttons">
<button onclick="booking()">我要訂購</button>
<button onclick="understandus()">認識工廠</button>
</div>
</section>
</div>
CSS
* {
padding: 0;
margin: 0;
}
/* 以下為標題的設定 */
.wrap {
font-family: "Segoe UI", "Open Sans", "Helvetica Neue", sans-serif;
width: 100%;
height: 100vh;
background-image: linear-gradient(0deg, #e66465, #9198e5);
}
h1 {
padding: 10px 0;
font-size: 20px;
text-align: center;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
}
section {
height: 80vh;
width: 100%;
margin: 0 auto;
display: flex;
flex-direction: column;
align-items: center;
}
.memberName {
padding: 5px;
height: 20px;
}
.memberName label {
height: 20px;
}
.memberName input {
height: 20px;
border-radius: 80px;
outline: 0;
border: 1px solid rgb(255, 255, 255, 0.4);
caret-color: transparent;
background-color: transparent;
padding: 5px;
font-size: 18px;
}
.memberName input:focus {
border: 1px rgb(255, 255, 255, 0.4) solid;
box-shadow: 1px 2px 1px rgb(255, 255, 255, 0.4);
}
/* 以下為按鈕的設定 */
.buttons {
margin: 15px;
}
button {
border-radius: 80px;
padding: 3px 18px;
width: 100px;
height: 40px;
opacity: 1;
font-size: 10px;
color: #eeeeed;
background-color: rgb(222, 195, 204);
transition: all 1.2s;
border: none;
}
button:hover {
opacity: 0.7;
}
JavaScript
function booking() {
var Name = document.getElementById("memberName").value;
alert(
Name +
"您好!謝謝您對我們的衣服有興趣!請致電 0987-654-321,會有專人提供您報價"
);
}
function understandus() {
alert("我們工廠位於新北市,通過國際 ISO9001 認證,品質讓您放心!");
}