Javascript导入html有可能吗? [英] Javascript import html is it possible?

查看:114
本文介绍了Javascript导入html有可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些相同页脚的html页面。使用JavaScript,只有javascript可以导入其中的另一个html页面吗?

I have some html pages with the same footer. With javascript and only javascript could i import another html page inside it?

推荐答案

如上所述,一种方法是使用jQuery加载。我碰巧正在做同样的事情,所以会发布一个简单的例子。

As above, one method is to use jQuery load. I happened to be doing the exact same thing now, so will post a quick example.

使用jQuery:

$("#yourDiv").load('readHtmlFromHere.html #readMe');

您的readHtmlFromHere.html页面将由以下内容组成:

And your readHtmlFromHere.html page would consist of:

<div><div id="readMe"><p>I'm some text</p></div></div>

这篇关于Javascript导入html有可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆