2011-02-28 72 views

回答

1

如果你想获得一个特定的td从表,并设置其属性,那就试试吧。

首先给它的td一个唯一的类名或id。

使用ID,写

$('#td1").attr("nowrap","nowrap"); 

使用类,写

$('.td1").attr("nowrap","nowrap"); 
1

尝试使用nowrap attribute

<td nowrap="nowrap">

用css这应该与div元素的工作,不知道TD

<style type="text/css"> 
.nowrap { 
    white-space: nowrap; 
} 
</style> 

<div class="nowrap">Content here</div> 
+0

使用CSS的+1 – bluish 2011-03-31 12:52:13

0

使用attr函数。还请检查here。它说NOWRAP已被弃用。而是使用CSS

<script> 
$(function() {   
     var cell = $('<td></td>').attr({'NOWRAP': 'NOWRAP'}).appendTo('.tr').html('asdfsd'); 
}); 
</script> 

<table> 
    <tr class='tr'><tr> 
</table> 
1
var $cell = $('td'); 
$cell.css("white-space", "nowrap");