因为循环不起作用我做错了什么?

时间:2018-01-31 08:17:46

标签: javascript jquery css

嗨,有人可以帮助我,我做错了什么..? 这是我的for循环,但它不起作用..

$(document).ready(function() {
  for (h = 1; h <= 4 h++) {
    var matchlinestatic = $('#matchline-static' + h).height();
    var matchlinedynamic = $('#matchline-dynamic' + h).height();
    console.log(matchlinestatic);
    console.log(matchlinedynamic);
    var result = Math.max(matchlinestatic, matchlinedynamic);
    var result = result + 'px';
    $("#matchline-static" + h).css('height', result);
    $("#matchline-dynamic" + h).css('height', result);
    console.log(result);
  }
});

1 个答案:

答案 0 :(得分:3)

错字,分号丢失,您也可以添加声明:

for (var h = 1; h <= 4; h++) { 
     ^^^              ^