我正在使用似乎显示不正确的代码。在我的滑块中,显示了多种产品。脚本运行时,应从每种产品中获取零售价。
目前,它只是抢占第一个产品的零售价。一些滑块也会显示零售价,而不会删除。
任何建议都可以帮上忙,对此我表示感谢。
<script type="text/javascript">
var ajax_load = " ";
var loadMagaziner = "/spotlite-deals/";
$("#SpotliteDeals .slider-block .ProductList").html(ajax_load).load(loadMagaziner + " .ProductList li", function(){
var $window = jQuery(window),
flexslider = { vars:{} };
// tiny helper function to add breakpoints
function getGridSize() {
return (window.innerWidth < 601) ? 1:
(window.innerWidth < 900) ? 1 : 1;
}
// check grid size on resize event
$window.resize(function() {
var gridSize = getGridSize();
flexslider.vars.minItems = gridSize;
flexslider.vars.maxItems = gridSize;
});
jQuery('#SpotliteDeals .BlockContent .slider-block').flexslider({
animation: "slide",
//selector: 'ul.ProductList > li',
slideshow: false,
itemWidth: 285,
controlNav: true,
minItems: 1, // use function to pull in initial value
maxItems: 1 // use function to pull in initial value
});
var rprice = jQuery(this).find('.p-price .RetailPriceValue').html();
var sprice = jQuery(this).find('.p-price .SalePrice').html();
if(rprice && sprice ){
var newrp = rprice.replace('$','');
var newsp = sprice.replace('$','');
var newds = Math.round(((newrp-newsp)/newrp)*100);
jQuery(this).find('.p-price .RetailPriceValue').append().html('Price: <strike>' + rprice + '</strike> (' + newds + '% off)' );
jQuery(this).find('.deal-tag').css('display','block');
} else {
jQuery(this).find('.deal-tag').css('opacity','0');
}
});
</script>