繁体   English   中英

如何将一个类从一个文件嵌入到另一个文件?

[英]How to embed a class from one file to another?

有没有办法在我网站的另一个页面中嵌入课程? 可以说我在“ index.html”页面中有此代码

<div class="cls1">
  content of div...
</div>

我想将其嵌入到我网站的另一个页面“ anotherpage.html”中。 所以我做:

<iframe src"?"></iframe>

我应该放什么呢?

注意,我只想从第一个文件中提取具有相同类的div

您可以将html分为两个文件,然后将iframe添加到另一个文件。

第一个文件:

<div class="something">
Tralala
</div>

第二档:

<iframe src="/path/to/your/first/file.html">
</iframe>

iframe需要src(源)参数,该参数应该是放置html文件的有效网址。 但是,您可以使用javascript来假定这种行为。

以jquery为例:

$('.div2').html($('.div1').html());

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM