我的 JS 代码在这里有两个问题,非常感谢任何帮助......
我需要添加一个逻辑,以便当产品价格为 499 美元时,过滤列表中会显示“超过 50 个”选项。就我目前的实现而言,这是行不通的。
<li> <!-- over 50 product is not showing when filtering --> <a href="/product-three">Product Four</a><br> <span id="lowestPriceRange">400</span> <span id="highestPriceRange">400</span> </li> // Because I need to handle it here somehow but I'm stuck var hidePrices = {}; hidePrices[0] = true; hidePrices[10] = true; hidePrices[20] = true; hidePrices[30] = true; hidePrices[40] = true; hidePrices[50] = true; $('#products').find('span').each(function(i, el){ var key = parseInt(Math.floor($(this).html() / 10) * 10, 10); hidePrices[key] = false; }); $('#filterByPrice').find('li').each(function(i, el){ if (hidePrices[Number($(this).find('a').attr('name'))]) { $(this).hide(); } });
它隐藏了一些我想展示的产品。For example, I want to show a product priced between $40 - $60 when the $40 - $50 filtering option is selected.