When i use style
property on JavaScript for an existence element it return to me an empty string
alert(element.style.width);
JavaScript return an empty alert box i tried this with many predeclared css property but the same output
var images = document.querySelectorAll(".slider_image");
document.getElementById("next").onclick = function() {
for (var i = 0; i < images.length; i++) {
alert(images[i].style.width);
}
};
And here is the html
<div id="first-part">
<div id="slider">
<img src="img/1.jpg" class="slider_image" id="1"/>
<img src="img/2.jpg" class="slider_image" id="2"/>
<img src="img/3.jpg" class="slider_image" id="3"/>
<img src="img/next.png" id="next-img"/>
</div>
<span id="next">Next</span> <span id="before">Before</span>
</div>
And here is my css :
.slider_image{
width:100%;
position:relative;
right:0px;
}
What might cause this ?