Javascript examples for CSS Style Property:backgroundPosition
Get the position of the background-image in a <div> element:
<!DOCTYPE html> <html> <body> <button type="button" onclick="myFunction()">Get background position</button> <br> <div id="myDiv" style="background: url('http://java2s.com/resources/a.png') no-repeat center;height:500px;width:500px;border:1px solid black;"> </div>/*from ww w . ja v a 2 s .c om*/ <script> function myFunction() { console.log(document.getElementById("myDiv").style.backgroundPosition); } </script> </body> </html>