簡體   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