Javascript 显示中的不可见链接:可见
已经潜伏了一段时间,但这是我的第一篇帖子。请对我放松点!:-) 我在一个表格中设置了一个faq页面,其中有一个“内容”列表,单击“显示”按钮时,主体就会显示出来 当display:none tr更改为display:block时,通过单击“show”按钮,它可以工作,除非我有一个Javascript 显示中的不可见链接:可见,javascript,html,displayobject,Javascript,Html,Displayobject,已经潜伏了一段时间,但这是我的第一篇帖子。请对我放松点!:-) 我在一个表格中设置了一个faq页面,其中有一个“内容”列表,单击“显示”按钮时,主体就会显示出来 当display:none tr更改为display:block时,通过单击“show”按钮,它可以工作,除非我有一个,上面有您的需求和目的的摘要,如果我们能够提供帮助,我们会这样做。 此时,网站上的搜索条件被有意限制。 隐藏 有什么想法吗 更新 考虑到李斯特先生关于从我想隐藏/显示的行中删除样式的建议,我又看了一眼——基本上链接还是
,上面有您的需求和目的的摘要,如果我们能够提供帮助,我们会这样做。
此时,网站上的搜索条件被有意限制。
隐藏
有什么想法吗
更新考虑到李斯特先生关于从我想隐藏/显示的行中删除样式的建议,我又看了一眼——基本上链接还是看不见的 我把页面和CSS文档放在我的桌面上,然后从那里加载页面,因为我认为它可能是从CSS中拉下来的 链接显示正确,除了保存文件的位置外,没有任何更改 现在我真的很困惑 更新
<script>
function hidetr(tr) {
document.getElementById(tr).style.display="none";
}
function showtr(tr) {
document.getElementById(tr).style.display="block";
}
</script>
分类!嗯……还没有,但我知道这是什么,所以我只需要几分钟
在这个主页上,我有一些PHP包含的其他文档,包括我的navbar,其中有一些样式标记。其中有一个a{color:white;}导致这个链接也是白色的
我发现如果我将页面更改为HTML而不是PHP,那么颜色是正确的,所以我认为它一定是服务器端包含的内容
感谢大家的评论,他们帮我整理了一些代码,为我指明了正确的方向
特别感谢李斯特先生
请有人把这个关上。它不允许我回答我自己的问题,因为我已经7个小时没见过面了。显示值取决于元素。我发现这是一个很好的解决方案:
function showtr(tr)
{
document.getElementById(tr).style.display="";
}
这使浏览器可以为图元类型选择默认值
或者,如果您不反对使用jQuery,那么它们的toggle()函数非常好:
您需要有有效的标记,您缺少一些标记 更新代码: 演示: HTML:
<table>
<tr>
<th>
I want to search for registrations in a certain area/by a certain date/by some other criteria that the site does not allow?<button onclick="showtr('faq5')">Show!</button>
</th>
</tr>
<tr id="faq5" style="display:none">
<td>
Please <a href="contactus.php">Contact Us</a> with a summary of your requirements and purpose and if we are able to help we will do. At this time the search criteria on the site are purposefully limited.
<button onclick="hidetr('faq5')">hide!</button>
</td>
</tr>
</table>
另外,你应该尝试一个像这样的库,它会让你的生活变得更加轻松。好的,我重新创建了你的情况,并在TR中使用DIV使其工作,而不是使用CSS类名隐藏/显示该DIV,而不是整个TR: CSS JS HTML
我想搜索某个地区/某个日期/某个网站没有的其他标准的注册
允许?表演!
请提供您的要求和目的的摘要,如果我们能够提供帮助,我们将提供帮助。此时,网站上的搜索条件被故意限制。隐藏!
它不是div,而是tr,所以显示值应该是
表行
。我认为这不能解决问题。如果从tr
中删除style属性,则行在开始时可见。那么链接可以吗?我的意思是,它对我有效,看(即使是“块”)。我试图在不同的浏览器上复制它,但没有一个显示出你的问题。也许可以更正表的结构,看看是否是格式错误的表标记导致了问题。您正在使用哪个浏览器?它是标记:。这就是我所改变的一切。@A.M.K.通过删除最后一个
,您将其更改为糟糕的HTML。为什么?这是个好答案,但这不是OP问题的原因。如果放置“块”或“表行”,则示例中的技术同样有效。所以还有其他一些地方出了问题。它在所有浏览器上都同样有效吗?有些人比其他人更宽容。是的,我在一些浏览器中尝试过,但仍然无法复制错误。我的下一个想法是HTML中缺少一些结束标记(正如其他海报所提到的),但很难确定,因为我们只看到了他整个页面的一小部分。也许他的桌子很整齐,他只是在按下按钮后才停止复制。也许一个元素有一个重复的id?对不起,但是“你需要有有效的标记(不是HTML5,yipee!!)”是什么意思?我希望我误解了你。顺便说一句,我确信OP的例子只是一个更大的HTML文档的一个小片段,没有丢失的标签。可能这是我看到的唯一问题,你永远也不知道。我犯了一个错误,HTML5中的“self-closing”标记不包括表。但是HTML5没有任何self-closing标记,只有XHTML有。HTML5可以通过错误恢复机制处理自动关闭标记,但HTML4也可以。另一方面,您指的是可选的结束标记,而不是自动关闭标记,对吗?是的。如上所述,我犯了一个错误。
<table>
<tr>
<th>
I want to search for registrations in a certain area/by a certain date/by some other criteria that the site does not allow?<button onclick="showtr('faq5')">Show!</button>
</th>
</tr>
<tr id="faq5" style="display:none">
<td>
Please <a href="contactus.php">Contact Us</a> with a summary of your requirements and purpose and if we are able to help we will do. At this time the search criteria on the site are purposefully limited.
<button onclick="hidetr('faq5')">hide!</button>
</td>
</tr>
</table>
function hidetr(tr){
document.getElementById(tr).style.display="none";
}
function showtr(tr){
document.getElementById(tr).style.display="block";
}
div.hidden{
display: none;
}
div.normal{
display: block;
}
function showtr(tr){
document.getElementById(tr).className = 'normal';
}
function hidetr(tr){
document.getElementById(tr).className = 'hidden';
}
<table>
<tr>
<th>I want to search for registrations in a certain area/by a certain date/by some other criteria that the site does not
allow?<button onclick="showtr('faq5')">Show!</button></th>
</tr>
<tr>
<td>
<div id="faq5" class="hidden">
Please <a href="contactus.php">Contact Us</a> with a summary of your requirements and purpose and if we are able to help we will do. At this time the search criteria on the site are purposefully limited.<button onclick="hidetr('faq5')">hide!</button></div>
</td>
</tr>
</table>