+ 2
What's wrong with my code?
var target = document.getElementById("target"); var yt = target.getAttribute("top"); alert(yt); Returns null, but top is defined in the css of target as top: 50px; Is it a sintax problem or it is not the apropiate way to get the value? please help me
5 ответов
+ 13
var yt = target.style.top;
+ 6
Attributes are something like href in <a href="#">. They are not equivalent to styles in CSS.
+ 6
Thank you both for helping me 😁
+ 3
At the end I don't know why using var yt =target.style.top didn't work for what I needed (I wanted to compare between two elements) but I found .offsetTop worked fine thank you both 😊
+ 2
You are good madam,congratulation i like you for your learning effort,