Get the value of the background-attachment property - Javascript CSS Style Property

Javascript examples for CSS Style Property:backgroundAttachment

Description

Get the value of the background-attachment property

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body style="background:#f3f3f3 url('http://java2s.com/resources/c.png') no-repeat fixed;">

<h1>Hello World!</h1>

<p>The background-image is fixed.</p>
<p>The background-image is fixed.</p>
<p>The background-image is fixed.</p>
<p>The background-image is fixed.</p>
<p>The background-image is fixed.</p>
<p>The background-image is fixed.</p>

<button onclick="myFunction()">Get background-attachment value</button>

<script>
function myFunction() {// w  w w.  j a v  a2  s .  co  m
    console.log(document.body.style.backgroundAttachment);
}
</script>

</body>
</html>

Related Tutorials