将文本链接到另一个页面 [英] Link text to another page
问题描述
我重新编辑了这个问题,因为我不确定这些答案是否适合.
这是一个代码(index.html):
我需要什么:
我需要另一个页面 (text.html),通过更改我将能够编辑此页面的文本.
所以如果页面 (text.html) 将显示:文本区域 =二二两个
(index.html) 中的 textarea 也会相应地更新和更改.
你需要知道的第一件事是你需要 jQuery,更具体地说,它的 load()
函数可以让你从同一域中的其他页面到另一个页面
您需要像这样包含 jQuery 库:
您可以使用 jQuery.load()
函数来从另一个页面获取数据
$("#").load();
这是一个完整的例子:
index.html
text.html:
<script src="https://code.jquery.com/jquery-3.6.0.min.js";完整性=sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="crossorigin=匿名"></script>头部><身体><div id='内容'>
<脚本>$( "#content" ).load( "index.html #myInput1" )
I have reedited the question as I'm not sure that any of those answers fit.
Here is a code (index.html):
<textarea id="myInput1" class="one" name="myInput1" readonly>
One
One
One</textarea>
</div>
What do I need:
I need to have another page (text.html), by changing which I will be able to edit this page's text.
So if the page (text.html) will display: textarea = Two Two Two
The textarea in the (index.html) will also update and change accordingly.
The first thing you need to know is that you need jQuery and more specifically its load()
function that lets you load data from other pages in the same domain onto another page
You need include the jQuery library like so:
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
You can use the jQuery.load()
function to get data from another page
$("#<parent div>").load(<content id>);
Here is a complete example of this:
index.html
<textarea id="myInput1" class="one" name="myInput1" readonly>
One
One
One
</textarea>
<p><a href='text.html'>link to next Page</a><p>
text.html:
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
</head>
<body>
<div id='content'>
</div>
<script>
$( "#content" ).load( "index.html #myInput1" )
</script>
</body>
这篇关于将文本链接到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!