当它是数字显示文本中心时,否则显示文本

时间:2016-12-09 11:13:30

标签: javascript jquery javascript-events javascript-objects

数字必须居中对齐,文字必须保持对齐

我的代码中出现错误。谁能告诉我我做错了什么

图像

enter image description here

代码



 color = color !== "" && color !== undefined ? " <span class=\"color\" style=\"background: #" + color + "\"></span>" : " <span class=\"color\"></span>";
contentHtml += "<td rowspan1=\"" + 1 + "\" class=\"" + (rowspan !== "" && rowspan > 1 ? "groups" : "") + " " + (typeof value == Number) ? "text-center" : "text-left" + "\">" + value + (Number(value) ? preFix : "") + color + (Number(value) ? postFix : "") + "</td>";
if (rowspan > 1) {
 var rowspanContent = "<td rowspan1=\"" + rowspan + "\" class=\"" + (rowspan !== "" && rowspan > 1 ? "groups" : "") + " " + (typeof value == Number) ? "text-center" : "text-left" + "\">" + value + (Number(value) ? preFix : "") + color + (Number(value) ? postFix : "") + "</td>"; }
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

将三元语句(typeof value == Number) ? "text-center" : "text-left"括在方括号中,以便在使用的两种情况下都具有... + ((typeof value == Number) ? "text-center" : "text-left") + ...