Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我想把我的卡片附加到另一个html页面_Html - Fatal编程技术网

我想把我的卡片附加到另一个html页面

我想把我的卡片附加到另一个html页面,html,Html,在这里,我从一个html中获取所有值,现在我想附加到另一个html页面。我该怎么办 $'.fa购物车加号'。单击功能{ var images=$this.attr'src'; var price=$this.attr'data-name'; var con=$this,'.modal body>p'.parent.html; $'tom'。追加×;+con+ }; 如果我理解正确,你的应用程序中有两个html文件,你希望在重定向时第一页的内容可以在另一页上使用。 如果是这样,您需要保

在这里,我从一个html中获取所有值,现在我想附加到另一个html页面。我该怎么办

$'.fa购物车加号'。单击功能{ var images=$this.attr'src'; var price=$this.attr'data-name'; var con=$this,'.modal body>p'.parent.html; $'tom'。追加×;+con+
}; 如果我理解正确,你的应用程序中有两个html文件,你希望在重定向时第一页的内容可以在另一页上使用。 如果是这样,您需要保存数据,因为重定向时会丢失数据。最好的方法是将数据保存到后端数据库。但是,如果没有数据库,可以使用localStorage。 试试这个:

// ......
var con = $(this, '.modal-body>p').parent().html();
var cards=[];   // Added code from here
cards.append("{your_content}");    //Replace `{your-content}` with your content
localStorage.setItem('cards', {cards});
现在,在另一条路线上,您可以使用以下方法从中获取数据:

const cards = localStorage.getItem('cards');
$("#tom").html(cards);
参考:


希望能有帮助。干杯

你什么意思?