I have a loop which decreases the margin-top by 182px every iteration. I want to get the value of margin-top so I can tell it when to stop running but when I try run it in console, it returns "undefined" Please advise how to change this to get the real value.
Here is what I am using, I am using attr() because the value it needs to get is an inline style:
$marginTop = $('.emp-wrap').attr("style");
The rest of the code is below
// if statements to move carousel up
$carouselNum = $('.carousella').length;
$marginTop = $('.emp-wrap').attr("style");
if($carouselNum > 1){
// // function empMove, the '-=' allows the -margin-top to run every time. Without this it will set the margin-top to the same value every loop
function empMove() { $('.emp-wrap').css('margin-top', '-=182')};
setInterval(empMove, 20000);
}
else if($carousel < 1){
// do something
}
else{
// do something
}
$marginTop = $('.emp-wrap').attr("style");inside theempMove()function?