将文本链接到另一个页面 [英] Link text to another page

查看:59
本文介绍了将文本链接到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我重新编辑了这个问题,因为我不确定这些答案是否适合.

这是一个代码(index.html):

我需要什么:

我需要另一个页面 (text.html),通过更改我将能够编辑此页面的文本.

所以如果页面 (text.html) 将显示:文本区域 =二二两个

(index.html) 中的 textarea 也会相应地更新和更改.

解决方案

你需要知道的第一件事是你需要 jQuery,更具体地说,它的 load() 函数可以让你从同一域中的其他页面到另一个页面

您需要像这样包含 jQuery 库:

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屋!

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