这是一个基于另一个问题答案的问题。
请看这个:
Export to CSV using jQuery and html
关于代码text = $col.text();
如果有CSS:在内容之前,我得到text = " "
,因为单元格是
<td><div id="state" class="state-c"> </div></td>
但实际上生成的HTML因为CSS样式而在该单元格中显示一个字符串:
.state-c:before {
content: "Confirmed";
}
我尝试过:
text = $col.text();
if (text.length < 2) { // text.length is always longer than 2 except when is = " "
text = window.getComputedStyle($('#state')[0], ':before').content;
}
此代码的许多变体如window.getComputedStyle($(col)[0], ':before').content;
等,但我无法找到使其在该代码中工作的方法,而它在其他上下文中完美运行。
是否有可能获得CSS的字符串:在以上述方式内容之前?