JS第三課作業
修改 html 的內容
by igorrrrr
HTML
<div class="orderWrap">
<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>
<div class="orderContent">
<p>您的訂單</p>
<p>顧客姓名:<span id="OrderNameText"></span></p>
</div>
</section>
</div>
CSS
* {
padding: 0;
margin: 0;
}
/* 以下為標題的設定 */
.orderWrap {
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 {
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;
border-radius: 10px;
}
button:hover {
opacity: 0.7;
}
.orderContent {
font-size: 16px;
border: 1px solid rgb(255, 255, 255, 0.4);
margin: 15px;
width: 40vw;
padding: 10px;
border-radius: 10px;
}
.orderContent p {
line-height: 1.5;
height: 1.5;
}
.orderContent p:first-child {
border-bottom: 1px solid rgb(255, 255, 255, 0.4);
}
JavaScript
function booking() {
var Name = document.getElementById("memberName").value;
alert(
Name +
"您好!謝謝您對我們的衣服有興趣!請致電 0987-654-321,會有專人提供您報價"
);
document.getElementById("OrderNameText").textContent = Name;
}
function understandus() {
alert("我們工廠位於新北市,通過國際 ISO9001 認證,品質讓您放心!");
}