javascript 如何将 nowrap 属性设置为 td 元素?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5138324/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set nowrap property to td element?
提问by JAB
This is what I tried:
这是我尝试过的:
function(nowrap) {
var cell = $(`'<td>'`);
//cell.wrap = wrap (not working)
}
回答by Paul Rowland
Try using nowrap attribute,
尝试使用nowrap 属性,
<td nowrap="nowrap">
<td nowrap="nowrap">
Using css this should work with div element, not sure about td
使用 css 这应该适用于 div 元素,不确定 td
<style type="text/css"> .nowrap { white-space: nowrap; } </style> <div class="nowrap">Content here</div>
<style type="text/css"> .nowrap { white-space: nowrap; } </style> <div class="nowrap">Content here</div>
回答by Deepak
If you wanna get a particular tdfrom table and set its property, then try it.
如果您想td从表中获取特定信息并设置其属性,请尝试一下。
First give a unique class name or id to its td.
首先为其td.
Using the ID, write
使用ID,写
$('#td1").attr("nowrap","nowrap");
Using the class, write
使用类,写
$('.td1").attr("nowrap","nowrap");
回答by Steve Wellens
var $cell = $('td');
$cell.css("white-space", "nowrap");

