gpt4 book ai didi

javascript - 表格行未拉伸(stretch)至 100% 宽度

转载 作者:行者123 更新时间:2023-12-01 02:15:06 24 4
gpt4 key购买 nike

我在单击 anchor 时隐藏并显示表格行,但是当下次显示 tr 时,它不会拉伸(stretch)到其完整长度。这是 demo

注意:转到查看差异并单击envVariable

这是我的代码

 var dummy1='<list>  <TagResult elementname="osname" subCategory="system" value1="Linux" value2="HP-US1000" isEqual="false"/>  <TagResult elementname="hostname" subCategory="system" value1="estilo" value2="benz" isEqual="false"/>  <TagResult elementname="release" subCategory="system" value1="2.6.18-128.el5" value2="B.11.23" isEqual="false"/><TagResult elementname="version" subCategory="system" value1="Red Hat Enterprise Linux Server release 5.3 (Tikanga)" value2="U" isEqual="false"/>  <TagResult elementname="machine" subCategory="system" value1="x86_64" value2="ia64 hp server rx2600" isEqual="false"/>  <TagResult elementname="bitmode" subCategory="system" value1="64" value2="64" isEqual="true"/>  <TagResult elementname="numberofcpu" subCategory="system" value1="4" value2="2" isEqual="false"/>  <TagResult elementname="cpuspeed" subCategory="system" value1=" 1862.890" value2="1400" isEqual="false"/>  <TagResult elementname="maxfilesperproc" subCategory="system" value1="32" value2=" 32" isEqual="true"/>  <TagResult elementname="maxthreadsperproc" subCategory="system" value1="2000000" value2="                    256  " isEqual="false"/><TagResult elementname="mempagesize" subCategory="system" value1="4096" value2="4096" isEqual="true"/><TagResult elementname="ssaname3webserviceserver" subCategory="product" value1="ssasvck&gt; Attempt 1 at server &apos;null:-1&apos;ssasvck&gt; Server&apos;null:-1&apos; is down" value2="ssasvck&gt; Attempt 1 at server &apos;null:-1&apos;ssasvck&gt; Server &apos;null:-1&apos; is down" isEqual="true"/><TagResult elementname="TERM" subCategory="envVariable" value1="xterm " value2="xterm" isEqual="true"/><TagResult elementname="JAVA_HOME" subCategory="envVariable" value1="/home/hqusers1/IIR_1152825121_estilo_9.0.1SP2_32 " isEqual="false"/><TagResult elementname="SSANUL" subCategory="envVariable" value1="/dev/null " value2="/dev/null" isEqual="true"/><TagResult elementname="SSA_LIHOST" subCategory="envVariable" value1="estilo:45682 " value2="benz:7660" isEqual="false"/><TagResult elementname="SSH_CLIENT" subCategory="envVariable" value1="10.65.6.131 4760 22 " value2="10.65.241.204 367222" isEqual="false"/></list>';

$('#compareForm input:radio').click(function() {
populateCompare($(this).val());
});

$('#compareTable a').live('click', function() {
var elementId=$(this).attr("id");
showHiddenTr(elementId);
});
function showHiddenTr(eid)
{
if($(".differentEnvironmentHiddentr").is(':visible'))
{
$(".differentEnvironmentHiddentr").css({"display":"none"});
}
else
{
$(".differentEnvironmentHiddentr").css({"display":"block"});
}
}


function populateCompare(cmp)
{
var mytr = new Array();
var mytrs="";
var i=0;
var xml=dummy1;
$('#compareContent').empty();
$('#compareContent').html("<table width='100%'><tbody><tr><td align='center'>Compare details being loaded</td></tr><tr><td align='center'><img src='/csm/view/include/images/loading.gif' alt='Loading'/></td></tr></tbody></table>");
if(cmp=="all")
{

$(xml).find('TagResult').each(function(){
if($(this).attr("isEqual")=="false")
{
mytr[i]='<tr class="regulartr">'+
'<td class="different" align="left">'+$(this).attr("elementname")+'</td>'+
'<td class="different" align="left">'+$(this).attr("value1")+'</td>'+
'<td class="different" align="left">'+$(this).attr("value2")+'</td>'+
'</tr>';
mytrs+=mytr[i++];
}
else
{
mytr[i]='<tr class="regulartr">'+
'<td class="nametd" align="left">'+$(this).attr("elementname")+'</td>'+
'<td class="value1td" align="left">'+$(this).attr("value1")+'</td>'+
'<td class="value2td" align="left">'+$(this).attr("value2")+'</td>'+
'</tr>';
mytrs+=mytr[i++];
}

});


$('#compareContent').empty();
$('<div>')
.html('<table id="compareTable" cellspacing="0" cellpadding="0">'+
'<thead><tr class="regulartr">'+
'<th align="center">Name</th>'+
'<th align="center">Config1</th>'+
'<th align="center">Config2</th>'+
'</tr></thead><tbody>'+mytrs

+'</tbody></table>')
.appendTo('#compareContent');

}
if(cmp=="diff")
{
var env=0;
$(xml).find('TagResult').each(function(){

if($(this).attr("isEqual")=="false")
{
if($(this).attr("subCategory")=="envVariable")
{
if(env==0)
{
mytr[i]='<tr class="regulartr">'+
'<td class="different" align="left"><a id="showCmpEnvironment"><img src="http://pslxcsm01:8080/informaticaCSM/zkau/web/zul/img/tree/close.png"/>'+$(this).attr("subCategory")+'</a></td>'+
'<td class="different" align="left"></td>'+
'<td class="different" align="left"></td>'+
'</tr>';
mytrs+=mytr[i++];
mytr[i]='<tr class="differentEnvironmentHiddentr">'+
'<td class="different" align="left">&nbsp;&nbsp;'+$(this).attr("elementname")+'</td>'+
'<td class="different" align="left">'+$(this).attr("value1")+'</td>'+
'<td class="different" align="left">'+$(this).attr("value2")+'</td>'+
'</tr>';
mytrs+=mytr[i++];
env=1;
}
else
{


mytr[i]='<tr class="differentEnvironmentHiddentr">'+
'<td class="different" align="left">&nbsp;&nbsp;'+$(this).attr("elementname")+'</td>'+
'<td class="different" align="left">'+$(this).attr("value1")+'</td>'+
'<td class="different" align="left">'+$(this).attr("value2")+'</td>'+
'</tr>';
mytrs+=mytr[i++];
}
}
else
{
mytr[i]='<tr class="regulartr">'+
'<td class="different" align="left">'+$(this).attr("elementname")+'</td>'+
'<td class="different" align="left">'+$(this).attr("value1")+'</td>'+
'<td class="different" align="left">'+$(this).attr("value2")+'</td>'+
'</tr>';
mytrs+=mytr[i++];
}



}


});


$('#compareContent').empty();
$('<div>')
.html('<table id="compareTable" cellspacing="0" cellpadding="0">'+
'<thead><tr class="regulartr">'+
'<th align="center">Name</th>'+
'<th align="center">Config1</th>'+
'<th align="center">Config2</th>'+
'</tr></thead><tbody>'+mytrs

+'</tbody></table>')
.appendTo('#compareContent');

}
}

最佳答案

trdisplay 属性的默认值为 table-row 而不是 block。它应该在 nonetable-row 之间切换。请参阅http://jsfiddle.net/aQPZk/

关于javascript - 表格行未拉伸(stretch)至 100% 宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6610604/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com