PHP array traversal problem, js problem, mainly click on the product thumbnail, the click event will be enlarged,
Now click on the first picture and the following pictures are all the first enlarged pictures
The code is as follows
{ foreach from=$goods_list item=goods}
<code> <a href="javascript:void(0);" onclick="picClose();"> <img src="{$goods.original_img}" /></a>
</div></code>
Reply content:
PHP array traversal problem, js problem, mainly click on the product thumbnail, the click event will be enlarged,
Now click on the first picture and the following pictures are all the first enlarged pictures
The code is as follows
{ foreach from=$goods_list item=goods}
<code> <tr>
<td style="width: 10%;font-size: 16px;border-bottom:1px solid #ccc;"><a name='fff' href='javascript:void(0);' onclick='picBig();'><img style="width:50px;height: 50px;" src="{$goods.original_img}"/></a></td></code>
<code> <a href="javascript:void(0);" onclick="picClose();"> <img src="{$goods.original_img}" /></a>
</div></code>
Replace your picBig
code
<code>function picBig() {
var $ = document.querySelector.bind(document);
var img = event.currentTarget.children[0]; // 获取当前点击的图片
var url = img.getAttribute('src'); // 获取当前点击的图片地址
// 获取大图 img 元素并设置要显示的图片地址
$('#divCenter > a > img').setAttribute('src', url);
// 显示预览框
$('#divCenter').style['display'] = 'block';
}</code>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn