简体   繁体   中英

How to change the font size for the contents of a cell created using javascript

I have created a table using javascript . Here is the code

var table = document.createElement('TABLE');
table.border='1';
var tableBody = document.createElement('TBODY');
table.appendChild(tableBody);
var tr = document.createElement('TR');
var td = document.createElement('TD');
newString = td.appendChild(document.createTextNode(newString));
tr.appendChild(td);

How do i change the font size of the cell contents ? ie i want newString to be displayed in Font size 20.

Add

td.style.fontSize = '20px';

After

var td = document.createElement('TD');

http://jsfiddle.net/samliew/RFCwt/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM