javascript - Zen Cart 产品 div 上的可点击链接

标签 javascript html css

我一直在努力研究如何将链接包裹在 div 容器周围,以便使产品列表框成为指向产品信息页面的链接。我试过使用主页上显示的特价商品,但一无所获。

这是代码

 $list_box_contents = array();
while (!$specials_index->EOF) {
$products_price = zen_get_products_display_price($specials_index->fields['products_id']);

$products_description = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($specials_index->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION); //To Display Product Desc 

$products_description = ltrim(substr($products_description, 0, 39) . '...'); //Trims and Limits the desc

if (!isset($productsInCategory[$specials_index->fields['products_id']])) $productsInCategory[$specials_index->fields['products_id']] = zen_get_generated_category_path_rev($specials_index->fields['master_categories_id']);

$specials_index->fields['products_name'] = zen_get_products_name($specials_index->fields['products_id']);
$list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsSpecials centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
'text' => (($specials_index->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '   <div class="imagename"><div class="product_image">
<a href="' . zen_href_link(zen_get_info_page($specials_index->fields['products_id']), 'cPath=' . $productsInCategory[$specials_index->fields['products_id']] . '&products_id=' . (int)$specials_index->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $specials_index->fields['products_image'], $specials_index->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></div><div class="product_name">') . '<a href="' . zen_href_link(zen_get_info_page($specials_index->fields['products_id']), 'cPath=' . $productsInCategory[$specials_index->fields['products_id']] . '&products_id=' . $specials_index->fields['products_id']) . '">' . $specials_index->fields['products_name'] . '</a></div><div class="product_desc"><p class="s_desc">' . $products_description .'</p></div></div><div class="propricemain"><div class="prodprice">' . $products_price . '</div><div class="productbtn"><div class="mj-productdetailimage"><a href="' . zen_href_link(zen_get_info_page($specials_index->fields['products_id']), 'cPath=' . $productsInCategory[$specials_index->fields['products_id']] . '&products_id=' . (int)$specials_index->fields['products_id']) . '">More</a></div></div></div>');

我很乐意使用 css 或 jquery 来完成此任务。

最佳答案

用链接包装一个 div 听起来你想要完成这个:

<a href="product-page">
<div>
    Product information
</div>

虽然这可能适用于大多数浏览器,但它是非法的(语义上不正确),因为链接不应包含 div。

我个人的选择包括向 div 添加一个 onclick 行为,它可能看起来像这样:

<div style="cursor: pointer;" onclick="window.location='http://product-page';">
Product Information goes here.
</div>

如果您仍想“用链接包装”,您可以将您的更改为 a。

关于javascript - Zen Cart 产品 div 上的可点击链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19544308/

相关文章:

javascript - 如何将turn.js Flipbook放入父div中

javascript - 下拉列表中的值

javascript - 使用 jquery 清除元素的属性

html - 使用位置 :fixed 调整大小的 div 纵横比

html - 绝对位置高度和底部元素

html - 粘性页脚 html css 的问题

javascript - React.js 在从 Express.js 和 Restful api 获取响应之前等待 4 分钟

css - Google Chrome 输入类型 =“date” 强制

php - 尝试连接到数据库时不显示输出

javascript - 禁用 :active pseudo-class on z-index's layers