简体   繁体   English

如何显示引用同一个html文件中的id的纯文本内容

[英]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.

相关问题 将html文件的内容存储到jquery数组中 - store the content of an html-file into an jquery array 如何通过首先浏览将文本文件中的内容或html文件中的html代码加载到文本区域? - How to load the contents in the text file or the html codes in a html-file to a textarea by browsing it first? 如何替换html文件中多个标签的内容? [Node.js] - How to replace the content of multiple tags in html-file? [Node.js] 从同一子目录(Apache)将脚本加载到html文件中 - Load scripts in html-file from same subdirectory (Apache) 用 VanillaJS 而不是 jQuery 将 div 替换为另一个 html 文件('common/...html)的内容 - Replacing a div with the content of another html-file ('common/…html) with VanillaJS instead of jQuery 如何在extjs displayfield中将HTML标签显示为纯文本 - How to display HTML tags as plain text in extjs displayfield 加载在WebView中使用Javascript的HTML文件 - Load HTML-file that is using Javascript in a WebView Greasemonkey:突出显示 HTML 文件中的许多单词 - Greasemonkey: Highlight many words in a HTML-File 如何使用innerHTML作为纯文本获取div内容,然后将其下载为txt文件? - How to get div content with innerHTML as plain text and then download it as txt file? 如何在 ExtJs 中显示纯文本 - How to display plain text in ExtJs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM