ページ2のdivをJavaScriptでページ1に読み込む方法別のページからJavaScriptを使用してコンテンツを取得する
Page2.html
<html>
<head>
<title> title </title>
<body>
<div id="main">
<div id="content2"> this is content2</div>
<div id="content3"> this is content3</div>
</div>
</body>
</html>
私はリンクをクリックして削除された後、そのdiv要素の内容とのPage1にdiv要素を作成するために、PAGE2からID content2を取得し、使用したい、として同じことを行いますcontent3、content4を含む。その後、
<html>
<head>
<title> title </title>
<body>
<div id="main">
<div id="content1"> this is content1</div>
<a href="#"> get content</a>
</div>
</body>
</html>
そして
Page1.htmlはそのようになります。
<html>
<head>
<title> title </title>
<body>
<div id="main">
<div id="content1"> this is content1</div>
<div>this is content2</div>
<div>this is content3</div>
</div>
</body>
</html>
私はJavaScriptで新しく、これを行う方法はありません。誰かが助けることができれば。ありがとう。
編集:私はjavascriptのみでjqueryを使用しない方法が欲しかった。私は自分のプロジェクトをオフラインで作業したいと思っていますし、jqueryでそれを行うことはできません。私はjqueryプラグインをダウンロードし、それを私のディレクトリに貼り付けましたが、うまくいきませんでした。
可能な複製(http://stackoverflow.com/questions/20927573/get-another-pages-content-in-a-variable-with -ajax) –
フォームを見て、投稿してください。次に、jQuery '.post()'や 'AJAX'メソッドを調べます。これらはあなたが始めるのを助けるはずです... – Zak