Good day.

I am a beginner site writer. At the moment I am learning jQuery. Faced such a problem, there are two tables:

<table width="100%"> <tr> <td valign="top"> <table width="200px" border="1" id="first_table"> <tr> <td>2333<br>2 </td> </tr> </table> </td> <td valign="top"> <table width="200px" border="1" id="second_table"> <tr> <td>1 </td> </tr> </table> </td> </tr> </table> с id =first_table и id=second_table. 

So you need to find out the height of the first table and assign this height to the second table. I do a sample:

 $(document).ready(function () { var first_table_height = $('#first_table').attr('height'); $('#forresults').text('высота первой таблицы' + first_table_height); }); 

and it displays in me the "height of the first table - undefined". If I manually set the height of the first table, for example, 50px, then it displays "the height of the first table is 50px", and if you do not specify height, then undefined. What can be done so that it gives the height value, while not specifying the height value manually?

    2 answers 2

     var f_height = $('#first_table').height(); var s_height = $('#second_table').height(); 
    • Thanks helped! - duddeniska

    Work with height of elements