[英]How to display plain text content referencing an id in the same html-file
I had a hard time coming up with a descriptive title, but this is the best I could do. 我很难拿出一个描述性的标题,但这是我所能做到的。 Anyways, I'm following this tutorial about creating a hoverable menu and it works like a charm, but now comes the problem when I want to reference the id
无论如何,我正在按照本教程中有关创建可悬浮菜单的方式进行操作,它的工作原理就像一个超级按钮,但是现在当我要引用ID时出现了问题
<a href="#element1">Link 1</a>
I have set for the dropdown-content. 我已经为下拉菜单设置了内容。 I would want to do something like this in the same html-file:
我想在相同的 html文件中执行以下操作:
<div id="element1">
<article>
<h1>This is the page to element 1</h1>
<p> Some plain text... </p>
</article>
</div>
But this content only shows up on the index page and not on the page which I want to be dedicated to "element1". 但是此内容仅显示在索引页面上,而不显示在我要专用于“ element1”的页面上。 Now, you could probably make another html-file and reference to it, but as I was working with JQuery the other day, the above code worked the way I intended.
现在,您可能可以制作另一个html文件并对其进行引用,但是当我前几天使用JQuery时 ,上面的代码按照我的意图工作。
Is there any way to do this without another html-file or do you simply have to start writing some Javascript to make everything work? 没有其他html文件,有没有办法做到这一点,还是您只需要开始编写一些Javascript即可使一切正常工作?
Figured it out. 弄清楚了。 Just had to read up on JQuery and try out the show/hide options, and it worked.
只需阅读JQuery并尝试使用show / hide选项,就可以了。 I also needed to hide the content of an id with the style tag from the beginning.
我还需要从一开始就隐藏带有style标签的id的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.