Javascript DOM CSS Style backgroundRepeat Property set to no-repeat

Introduction

Set a background-image to no-repeat:

document.body.style.backgroundRepeat = "repeat-y";

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
body {/*  ww w . j a va2s .c o  m*/
  background: #f3f3f3 url('image1.png');
}
</style>
</head>
<body>

<h1>Hello World!</h1>

<button type="button" onclick="myFunction()">Set background image to no-repeat</button>

<script>
function myFunction() {
  document.body.style.backgroundRepeat = "no-repeat";
}
</script>

</body>
</html>



PreviousNext

Related