Return the position of the background-image in a <div> element:
document.getElementById("myDiv").style.backgroundPosition;
<!DOCTYPE html> <html> <body> <button type="button" onclick="myFunction()">Get background position</button> <br> <div id="myDiv" style="background: url('background1.png') no-repeat center;height:500px;width:500px;border:1px solid black;"> </div>/*from ww w . j a v a 2s . c o m*/ <p id="demo"></p> <script> function myFunction() { document.getElementById("demo").innerHTML =document.getElementById("myDiv").style.backgroundPosition; } </script> </body> </html>