คุณสมบัติ DOM style outlineStyle จะคืนค่าและแก้ไขรูปแบบของโครงร่างรอบองค์ประกอบในเอกสาร HTML
ไวยากรณ์
ต่อไปนี้เป็นไวยากรณ์ -
-
ส่งคืน outlineStyle
object.style.outlineStyle
-
กำลังแก้ไขเค้าร่างสไตล์
object.style.outlineStyle = “value”
ตัวอย่าง
ให้เราดูตัวอย่างคุณสมบัติสไตล์ outlineStyle -
<!DOCTYPE html>
<html>
<head>
<style>
body {
color: #000;
background: lightblue;
height: 100vh;
}
p {
background-color: seagreen;
height: 200px;
width: 200px;
outline: 2px solid #000;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 40%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
}
</style>
</head>
<body>
<h1>DOM Style outlineStyle Property Example</h1>
<p></p>
<button onclick="add()" class="btn">Add outline</button>
<script>
function add() {
document.querySelector('p').style.outlineStyle = "dashed";
}
</script>
</body>
</html> ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -

คลิกที่ “เพิ่มโครงร่าง ” เพื่อเปลี่ยนรูปแบบของเค้าร่างรอบกล่องสีเขียว
