In my html file I have the following markup:
<div class="long_box">
<div class="image1"> <img src="images/image1.png"> </div>
<div class="image2"> <img src="images/image2.png"> </div>
<div class="image3"> <img src="images/image3.png"> </div>
</div>
In the css file I have applied the following style rules:
.long_box {
width: 3300px;
height: 768px;
position: absolute;
left: 10px;
top: 0;
}
In the javascript file I made a variable as:
var longbox = document.getElementsByClassName("long_box")[0];
Now when I try to recall the initial value of left
of long_box
as longbox.style.left
, I get an empty string ""
. But after I change the left
value with javascript, e.g. as as longbox.style.left = 100 + 'px
and then recall it's value then I get 100px
in the console. So,
How to get the initial value of style properties in javascript?