หากต้องการจัดรูปแบบภาพพื้นหลังไม่ให้ซ้ำกับ JavaScript ให้ใช้ backgroundRepeat คุณสมบัติ. ช่วยให้คุณกำหนดได้ว่าจะให้ภาพพื้นหลังซ้ำหรือไม่บนหน้า
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อเรียนรู้วิธีจัดรูปแบบภาพพื้นหลังเพื่อไม่ให้เกิดซ้ำด้วย JavaScript -
<!DOCTYPE html>
<html>
<body>
<button onclick="display()">Click to Set background image</button>
<script>
function display() {
document.body.style.backgroundImage = "url('https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg')";
document.body.style.backgroundRepeat = "no-repeat";
}
</script>
</body>
</html>