Change the backgroundRepeat property of a DIV element - Javascript CSS Style Property

Javascript examples for CSS Style Property:backgroundRepeat

Description

Change the backgroundRepeat property of a DIV element

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {/*from  w w  w. j  a va 2s  .com*/
    border: 1px solid black;
    width: 300px;
    height: 150px;
    background: url('http://java2s.com/resources/a.png') no-repeat;
}
</style>
</head>
<body>

<button onclick="myFunction()">Test</button>

<div id="myDIV">
<h1>Hello</h1>
</div>

<script>
function myFunction() {
    document.getElementById("myDIV").style.backgroundRepeat = "repeat-x";
}
</script>

</body>
</html>

Related Tutorials