Javascript DOM CSS Style clip Property get

Introduction

Return the clip property:

alert(document.getElementById("myImg").style.clip);

View in separate window

<!DOCTYPE html>
<html>
<body>

<button type="button" onclick="myFunction()">Return the value of the clip property</button><br>

<img id="myImg" 
     style="position:absolute;clip:rect(0px,60px,200px,0px);" 
     src="background1.png" 
     width="400" 
     height="332">

<p id="demo"></p>


<script>
function myFunction() {/*from  w  w  w . j  av a  2s .  c  om*/
  document.getElementById("demo").innerHTML = document.getElementById("myImg").style.clip;
}
</script>

</body>
</html>



PreviousNext

Related