本文介绍了在表格的一列上加上省略号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
如何在表格的一栏中添加省略号我将分享我的代码,请帮助.
Hi
how to add ellipsis in one column of a table i will share my code please help .
var td1 = document.createElement('td');
td1.setAttribute('width', '3%');
td1.setAttribute("align","center");
td1.innerHTML = r[i].platformNo;;
var td2 = document.createElement('td');
td2.setAttribute('width', '42%');
td2.setAttribute("align","center");
td2.innerHTML = r[i].originSchDepart + " - " + r[i].fromSchDepart;
*******************Here i want to add ellipsis so that if station name is more than 10 character it show dot********
var td3 = document.createElement('td');
td3.setAttribute('width', '45%');
td3.setAttribute("align","center");
td3.innerHTML = r[i].stationName + " (" + r[i].crsCode + ")";;
var td4 = document.createElement('td');
td4.setAttribute('width', '5%');
td4.setAttribute("align","center");
var td5 = document.createElement('td');
td5.setAttribute('width', '5%');
td5.setAttribute("align","center");
if(r[i].expArrival == r[i].schArrival)
{
td4.innerHTML = "<img src=\"images/correct-icon.png\" width=\"24\" height=\"24\" />";
td5.innerHTML="";
}
else
{
td4.innerHTML = "<img src=\"images/error.png\" width=\"24\" height=\"24\" />";
td5.innerHTML=r[i].expArrival;
}
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
tr.appendChild(td4);
tr.appendChild(td5);
tbl.appendChild(tr);
推荐答案
这篇关于在表格的一列上加上省略号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!