我试图在文件中插入一些文本到<textarea></textarea>
在HTML文件中,当你点击一个不同的HTML页面中的链接。插入文本到<textarea>
html1.html:
<a href="#" id="link">click to add text</a>
html2.html:
<form action="...">
<textarea id="txt"></textarea>
</form>
JS:
$(".link").click(function(){
window.location = "./html2.html";
var text = $("#some_id").text();
$("#txt").val(text)
});
在html1或html2中有'some_id'吗? – tskuzzy 2012-07-20 20:49:12
window.location =“./html2.html”;会立即加载一个新页面,覆盖当前页面。因此脚本的其余部分将不会运行。 – 2012-07-20 20:50:34
这里你最终的目标是什么?也许你没有看到它的工作,因为它真的让你到html2.html? – Zlatev 2012-07-20 20:51:16