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>
Copy after login
Copy after login
<code> <a href="javascript:void(0);" onclick="picClose();"> <img src="{$goods.original_img}" /></a>
</div></code>
Copy after login
Copy after login
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>
Copy after login
Copy after login
<code> <a href="javascript:void(0);" onclick="picClose();"> <img src="{$goods.original_img}" /></a>
</div></code>
Copy after login
Copy after login
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>
Copy after login
Statement of this Website
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
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31