如何将HTML文档添加到< div>< / div>通过JavaScript / JQuery?
如何通过JavaScript / JQuery将HTML文档添加到< div>< / div>
?
How do I add an HTML doc into a <div></div>
via JavaScript/ JQuery?
这是我到目前为止的情况;
This is what i have so far;
emailBodyInclude.html
emailBodyInclude.html
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/imports/reset.css" type="text/css" />
<script>
// JavaScript
</script>
</head>
<body>
<p>Hello world! This is HTML5 Boilerplate.</p>
</body>
</html>
使用JavaScript / JQuery,如何从HTML文档中删除任何形式的声明:
Using JavaScript/ JQuery, how can I go about removing from a HTML document any declarations of the form of:
<!DOCTYPE html>
<html class="no-js">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<head></head>
<body></body>
让我留下:
<link rel="stylesheet" href="css/imports/reset.css" type="text/css" />
<script>
// JavaScript
</script>
<p>Hello world! This is HTML5 Boilerplate.</p>
,以便我可以安全地将剩余的内容插入< div> ; / div>
so that I can safely insert what remains into a <div></div>
先谢谢大家。
UPDATE:
emailBodyInclude.html是从提供商(例如Yahoo)检索的HTML邮件字符串。它是动态的,并且没有办法告诉什么语法将是什么样子。我想将这个html文档包含在另一个。在< div class =htmlMail>< / div>
emailBodyInclude.html is a String of HTML mail retrieved from a provider, like Yahoo, for example. It is dynamic, and there is no way to tell what the syntax will look like. I would like to include this html document inside another. Inside a <div class="htmlMail"></div>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="../../baseCSS/bootStrap/bootstrap.min.css">
</head>
<body>
<div class="header">This is a HTML email</div>
<div class="htmlMail"></div>
</body>
</html>
http://api.jquery.com/load/rel =nofollow> http://api.jquery.com/load/
You can use load for this http://api.jquery.com/load/
$('.htmlMail').empty().load('emailBodyInclude.html');