开发者

setting valign property of <TD> in javascript [duplicate]

开发者 https://www.devze.com 2023-03-31 11:27 出处:网络
This question already has an answer here: Closed 11 years ago. Possible Duplicate开发者_如何学Python:
This question already has an answer here: Closed 11 years ago.

Possible Duplicate开发者_如何学Python:

valign not working on a td?

I'm adding rows to a table dynamically using javascript as following:

var lastRow = tbl.rows.length;
var iteration = lastRow;
var row = tbl.insertRow(lastRow);

var cellLeft = row.insertCell(0);
var inc = parseInt(iteration)+1;
var textNode = document.createTextNode(inc);
cellLeft.appendChild(textNode);

var cellMiddle = row.insertCell(1);
var el = document.createElement('input');
el.type = "checkbox";
cellMiddle.appendChild(el);

var cellRight = row.insertCell(2);
var el1 = document.createElement('span');
el1.innerHTML = "asdasd adad a aa a a s a a a  a as "+
           " a a as a a a  adasdadsadad ad ada aasdasd as aas  ";

Here I create a row with 3 columns one showing number, second contains checkbox and third one contains data. Here the data in 3rd column is very long and that's why it's height increases and checkbox and number in other cells are shown in middle. I want to set there valign proprty to top. How can I do that?

I've tried following line but did not worked:

cellLeft.valign="top";


You can do this using following javascript code :

cellLeft.style.verticalAlign = "top";
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号