

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to style background image to no repeat with JavaScript DOM?
To style the background image to no repeat with JavaScript, use the backgroundRepeat property. It allows you to set whether the background image repeats or not on a page.
Example
You can try to run the following code to learn how to style background image to no repeat with 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>
- Related Questions & Answers
- Repeat the background image with CSS
- How to set a background image to be fixed with JavaScript DOM?
- How to set the background image for an element with JavaScript DOM?
- Repeat the background image both horizontally and vertically with CSS
- HTML DOM Style background Property
- How to set the starting position of a background image in JavaScript DOM?
- How to set the size of the background image with JavaScript?
- Background Repeat in CSS
- Background Repeat Using CSS
- How to set the positioning area of the background image with JavaScript?
- How to create a blurry background image with CSS?
- How to return the background color of an element with JavaScript DOM?
- CSS border-image-repeat
- How to create a full-page background image with CSS?
- How to create a canvas with background image using FabricJS?
Advertisements