首页javascriptcss_attributejQuery Style - 如何如果存在CSS颜色,请添加CSS属性...

jQuery Style - 如何如果存在CSS颜色,请添加CSS属性...

我们想知道如何如果存在CSS颜色,请添加CSS属性。...

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    $(function() {
      console.log($(".testclass").css("margin-top"));
      console.log(parseInt($(".testclass").css("margin-top")));
    });
});
</script>
</head>
<body>
  <div class="testclass"
    style="margin-top: 30px; width: 200px; height: 200px; border: 1px solid #000;"></div>
</body>
</html>