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>