title: jQuery get computed CSS value
body: <p>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.</p>
  
  <p>Here is what I am using, I am using attr() because the value it needs to get is an inline style:</p>
  
  <pre><code>$marginTop = $('.emp-wrap').attr("style");
  </code></pre>
  
  <p>The rest of the code is below</p>
  
  <pre><code>// if statements to move carousel up
  $carouselNum = $('.carousella').length;
  
  $marginTop = $('.emp-wrap').attr("style");
  
  if($carouselNum  &gt; 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 &lt; 1){
      // do something
  }
  else{
      // do something
  }
  </code></pre>