我在名为Transactions.html的页面上有以下div:
<div class = "theListItem" data-role="collapsible-set" data-collapsed="false">
<div data-role="collapsible" data-collapsed="false" data-theme="a">
<h3>$12.62 - 11/01/2012 - Kelloggs Diner - Brooklyn Ny</h3>
<div data-role="controlgroup" data-type="horizontal">
<a class= "green" href="categorize.html" data-transition="slide" data-role="button">Yes</a>
<a class="red" href="#" data-role="button">No</a>
<a class="blue" href="IDK.html" data-transition="slideup" data-role="button">I'm not sure</a>
</div>
</div>
</div>
当我点击链接<a>No</a>
时,我希望整个div移动到另一个Summary.html页面。有任何想法吗?感谢
答案 0 :(得分:1)
你可以这样做。您需要有一个包装器div标签才能选择整个html内容。
<script language="javascript" type="text/javascript" src="jquery-1.8.2.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$('.red').click(function(){
var divData = $('#dataContainer').html();
window.location.href = "summarypage.html?data="+divData+"";
});
});
</script>
<div id="dataContainer">
<div class = "theListItem" data-role="collapsible-set" data-collapsed="false">
<div data-role="collapsible" data-collapsed="false" data-theme="a">
<h3>$12.62 - 11/01/2012 - Kelloggs Diner - Brooklyn Ny</h3>
<div data-role="controlgroup" data-type="horizontal">
<a class= "green" href="categorize.html" data-transition="slide" data-role="button">Yes</a>
<a class="red" href="#" data-role="button">No</a>
<a class="blue" href="IDK.html" data-transition="slideup" data-role="button">I'm not sure</a>
</div>
</div>
</div>
</div>
在摘要页面中,您需要从URL中检索数据。当您运行此链接并单击“否”链接时,它会导航到摘要页面,您可以在摘要页面URL栏上看到html值
您可以使用PHP使用<?php echo $_REQUEST['data']; ?>
答案 1 :(得分:0)
你不能 - 这不是网络的运作方式。每个HTML页面都是自包含和封装的。
有些网站,比如Github,使用JavaScript历史记录API和AJAX做一些小动作,使其看起来好像新页面“部分加载”,而实际上它是同一页面。
答案 2 :(得分:0)
您可能需要使用PHP或服务器端技术来存储数据,并且需要将静态页面完全转换为动态PHP页面,这需要大量工作。
答案 3 :(得分:0)
通过使用html,无法将数据从一个html文件传输到另一个html文件。使用JQuery来执行数据传输 通过使用Jquery中的load()来单击按钮,speficy,其中div或您想要显示数据的位置,您可以将另一个页面中的特定数据加载到您的页面