P
P
Pavel Antonov2017-02-14 09:50:30
JavaScript
Pavel Antonov, 2017-02-14 09:50:30

Why does the code not work correctly in safari?

I wrote the code, it works correctly in all browsers available to me, even on an iPhone in safari. But here on the desktop does not want to. The code compares the rows of the two tables and sets the height of the larger row. In safari, the code works, but it takes it crookedly and counts incomprehensible numbers.

the code itself

$(document).ready(function() {
  function recalcHeight(){
    $(".titles tr").each(function(){
      var height_title = $(this).height();
      var index_title = $(this).index();
      var height_value = $(".values tr").eq(index_title).height();
      console.log("высота "+index_title+"й строки левой таблицы равна - "+height_title+"px");
      console.log("высота "+index_title+"й строки правой таблицы равна - "+height_value+"px");
      
      if(height_title <= height_value){
        $(this).css("height", height_value);
      }else{
        $(".values tr").eq(index_title).css("height", height_title);
      }
    });
  }
  recalcHeight();
  $(window).resize(function() {
    recalcHeight();
  });
});


After resizing, everything becomes as it should

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Antonov, 2017-02-14
@freislot

found a jamb, dom loaded faster than pictures in the table, respectively, the lines were considered without the height of the picture, replaced
with
this solved the problem

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question