gpt4 book ai didi

html - CSS 显示无 - 隐藏

转载 作者:行者123 更新时间:2023-11-28 01:53:46 25 4
gpt4 key购买 nike

这里很迷茫。有类似的代码工作...

无法隐藏 td 或更改为 div 时也不显示...这不是冷聚变问题,我不认为...

必需的 Javascript

 <script type="text/javascript">
function showElement(layer){
var myLayer = document.getElementById(layer);
if(myLayer.style.display=="none"){
myLayer.style.display="block";
myLayer.backgroundPosition="top";
} else {
myLayer.style.display="none";
}
}
</script>

这个冷聚变代码一切正常,在表格中显示也很好......当我添加隐藏它的功能时 - 我无法让它显示......typeid每次都不一样...

 <table cellpadding=2 cellspacing=2 align=center border=1>
<cfoutput query=list group="typeid">
<cfquery name="gl" datasource="#ds#">
select * from shindates
where sdate <= #monthdate# and stime >= #createODBCDateTime(timenow)# and typeid = '#typeid#'
order by typeid, sdate
</cfquery>
<cfquery name="type" datasource="#ds#">
select * from type
where typeid = '#typeid#'
</cfquery>
<tr>
<td><img src="../images/edit.png" alt="Edit" width=25 border=0 alt="Show List" onclick="javascript:showElement('#typeid#')"></td>
<td valign=middle class=verd10>#type.type#</td>
</tr>
<tr>
<td colspan=2 id="#typeid#" style="display: none">

<cfloop query="gl">
<table cellpadding=5 cellspacing=5 align=center class=general>
<tr>
<td colspan=2>
#type.type# - #Dateformat(gl.sdate, 'dddd - mmm dd, yyyy')# - #Timeformat(gl.stime, 'HH:mm')#<br>
</td>
</tr>
<tr>
<cfset csigned = signedup + gsignedup>
<cfif csigned is not 0>
<td class=verd9 align=center><b>Unable to Cancel - Users Signed Up</b></td>
<td class=verd9 align=center>
<cfform action="adminmanage.cfm?shinid=#gl.shinid#" method="post">
<input type="submit" value="Manage List" class="legal8">
<input type="hidden" value="#gl.shinid#" name="shinid">
</cfform>
</td>
<cfelse>
<td class=verd9 align=center>
<cfform action="adminlist.cfm?src=del" method="post">
<input type="submit" value="Cancel" class="legal8">
<input type="hidden" value="#gl.shinid#" name="shinid">
</cfform>
</td>
<td class=verd9 align=center>
<cfform action="adminmanage.cfm?shinid=#gl.shinid#" method="post">
<input type="submit" value="Manage List" class="legal8">
<input type="hidden" value="#gl.shinid#" name="shinid">
</cfform>
</td>
</cfif>
</tr>
</table>

</cfloop>
</td>
</tr>
</cfoutput>
</table>

感谢任何帮助...

最佳答案

我测试了您的 JavaScript,它似乎在以下简化示例中运行良好:

<table cellpadding=2 cellspacing=2 align=center border=1>
<tr>
<td>
<img src="http://placehold.it/50x25" border=0 alt="Show List" onclick="showElement('#typeid#')">
</td>
<td valign=middle class=verd10>#type.type#</td>
</tr>
<tr>
<td colspan=2 id="#typeid#" style="display: none">The hidden content.</td>
</tr>
</table>

<script>
function showElement(layer) {
var myLayer = document.getElementById(layer);
if (myLayer.style.display == "none") {
myLayer.style.display = "table-cell";
myLayer.backgroundPosition = "top";
} else {
myLayer.style.display = "none";
}
}
</script>

查看第一个演示:http://jsfiddle.net/audetwebdesign/BPWR8/

我还按原样测试了您的 HTML/ColdFusion 代码段,JavaScript 仍然有效。
请参阅第二个演示:http://jsfiddle.net/audetwebdesign/xK6jv/

您确定您的 JavaScript 在页面中吗?

要点:您可能希望将显示设置为 table-cell 而不是 block

关于html - CSS 显示无 - 隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18420613/

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