我有一个产品页面,上面有 20 种左右的产品。当您单击产品链接时,我想将 2 个参数传递给它重定向到的页面,一个图像 src 和一个文本属性,然后将它们显示在 div 中。
ATM 我的代码设置了 title 和 img data 属性,使用 URL 字符串中的属性重定向到正确的页面,但我不确定如何正确显示此信息。
如何将 title 和 img 属性参数都传递给 lineup/index.html 页面,然后显示这两个属性?还有比将属性放在 URL 查询字符串中更好的方法吗?
产品链接
<a href="#" class="product" data-img="product1-img.jpg" data-title="Product1">More Information</a>
产品.js
jQuery(document).ready(function($){
$('.product').click(function(event) {
var name;
name = $(this).data('title');
window.location = './lineup/index.html?title=' + name + 'img' + img;
});
});
阵容/index.html
<div class="text_area">
<div id="title-area">TITLE ATTRIBUTE</div>
<div class="product-img">
IMG SRC
</div>
</div>
如果有人需要更多代码,请大喊,我只使用纯 HTML、javascript 和 jQuery。