Js style dynamically sets the table height and jsstyle dynamic table

Source: Internet
Author: User

Js style dynamically sets the table height and jsstyle dynamic table

Just set it in the table label? This is static. Do you want to set it dynamically?

function com_onresize(){var contentsHeight = document.body.clientHeight;var buttonsHeight = document.getElementById( "buttons" ).offsetHeight;var head1Height = document.getElementById( "head1" ).offsetHeight;var head2Height = document.getElementById( "head2" ).offsetHeight;var t1 = document.getElementById( "TableContainer1" ).style.height;var t2 = document.getElementById( "TableContainer2" ).style.height;//alert(document.getElementById( "TableContainer1" ).style.height);var h = contentsHeight - buttonsHeight - head1Height - head2Height - 13;if(h < 110){return;}document.getElementById( "TableContainer1" ).style.height = h/2 + 'px';document.getElementById( "TableContainer2" ).style.height = h/2 + 'px';}function com_sbs_pagesize(){var screenHeight = window.screen.height;  var availHeight = window.screen.availHeight;  //alert(document.getElementById( "TableContainer1" ).children[0].rows.length);  var index = document.getElementById( "TableContainer1" ).children[0].rows.length  var buttonsHeight = document.getElementById( "buttons" ).offsetHeight;var head1Height = document.getElementById( "head1" ).offsetHeight;var head2Height = document.getElementById( "head2" ).offsetHeight;  var mainH = buttonsHeight + head1Height +head2Height + 13;  //20:scroll 35:title 25:tr  while ((availHeight-mainH) < (20 + 35 + 25*index)*2){ index = index - 1;}var tableHeight = 20 + 35 + 25*index;  document.getElementById( "TableContainer1" ).style.height = tableHeight + 'px';  document.getElementById( "TableContainer2" ).style.height = tableHeight + 'px';  window.resizeTo(document.body.offsetWidth,mainH + tableHeight*2);} 

JS changes the table style

$ ('# Tableid') is a jquery object ,. style. height = "1000px" height is the size of the domobject. You can configure ('{tableid'}.css ("height", 1000); or you can reach the dom object $ ('# tableid '). get (0 ). style. height = "1000px ";
Document. getElementById ("'# tableID"). style. height = "1000px"

How to Use js to control the table height

<Table id = "t1"> </table>
<Script type = "text/javascript">
Var table = document. getElementById ("t1 ");

Table. setAttribute ("height", "Enter the value here ");

</Script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.