<div class="selectProduct" data-title="华为P9" data-id="华为P9" data-size="5.2"" data-weight="144 g" data-os="Android 6.0" data-processor="海思麒麟955 2.5GHz(8核)" data-battery="3000mAH"> <a class="btn-floating light-grey addButtonCircular addToCompare">+</a> <img src="images/huawei_p9.jpg" class="imgFill productImg"> <h4>华为 P9</h4> </div>
<div class="row"> <div class="col-md-12 comparePanle"> <div class="row"> <div class="col-md-9"> <h4>对比中的产品</h4> </div> <div class="col-md-3"> <button class="btn btn-default cmprBtn" disabled>开始对比</button> </div> </div> <div class="comparePan"></div> </div> </div>
<div id="id01" class="animate-zoom modal modPos">
<div class="modal-title">
<a onclick="document.getElementById('id01').style.display='none'" class="modal-closebtn">×</a>
</div>
<div class="row contentPop"></div>
</div>
var list = [];
//添加到对比项
$(document).on('click', '.addToCompare', function () {
$(".comparePanle").show();
$(this).toggleClass("rotateBtn");
$(this).parents(".selectProduct").toggleClass("selected");
var productID = $(this).parents('.selectProduct').attr('data-title');
var inArray = $.inArray(productID, list);
if (inArray < 0) {
if (list.length > 2) {
alert('最多只能选择3个产品');
$(this).toggleClass("rotateBtn");
$(this).parents(".selectProduct").toggleClass("selected");
return;
}
if (list.length < 3) {
list.push(productID);
var displayTitle = $(this).parents('.selectProduct').attr('data-id');
var image = $(this).siblings(".productImg").attr('src');
$(".comparePan").append('<div id="' + productID + '" class="relPos col-md-3 text-center"><a class="selectedItemCloseBtn closebtn">×</a><img src="' + image + '" alt="image" style="height:100px;"/><p id="' + productID + '" class="ptitle">' + displayTitle + '</p></div>');
}
} else {
list.splice($.inArray(productID, list), 1);
var prod = productID.replace(" ", "");
$('#' + prod).remove();
hideComparePanel();
}
if (list.length > 1) {
$(".cmprBtn").addClass("active");
$(".cmprBtn").removeAttr('disabled');
} else {
$(".cmprBtn").removeClass("active");
$(".cmprBtn").attr('disabled', '');
}
});
$(document).on('click', '.cmprBtn', function () {
if ($(".cmprBtn").hasClass("active")) {
/* this is to print the features list statically*/
$(".contentPop").append('<div class="col-md-3 compareItemParent relPos">' + '<ul class="product"><li class=" relPos compHeader">产品信息</li><li>名称</li><li>屏幕大小</li><li>重量</li><li>系统</li><li class="cpu">CPU</li><li>电池容量</li></ul></div>');
for (var i = 0; i < list.length; i++) {
/* this is to add the items to popup which are selected for comparision */
product = $('.selectProduct[data-title="' + list[i] + '"]');
var image = $('[data-title=' + list[i] + ']').find(".productImg").attr('src');
var title = $('[data-title=' + list[i] + ']').attr('data-id');
/*appending to div*/
$(".contentPop").append('<div class="col-md-3 compareItemParent relPos">' + '<ul class="product">' + '<li class="compHeader"><img src="' + image + '" class="compareThumb"></li>' + '<li>' + title + '</li>' + '<li>' + $(product).data('size') + '</li>' + '<li>' + $(product).data('weight') + '</li><li>'+ $(product).data('os') +'</li><li class="cpu">' + $(product).data('processor') + '</li>' + '<li>' + $(product).data('battery') + '</ul>' + '</div>');
}
}
$(".modPos").show();
});
$(document).on('click', '.modal-closebtn', function () {
$(".contentPop").empty();
$(".comparePan").empty();
$(".comparePanle").hide();
$(".modPos").hide();
$(".selectProduct").removeClass("selected");
$(".cmprBtn").attr('disabled', '');
list.length = 0;
$(".rotateBtn").toggleClass("rotateBtn");
});
$(document).on('click', '.selectedItemCloseBtn', function () {
var test = $(this).siblings("p").attr('id');
$('[data-title=' + test + ']').find(".addToCompare").click();
hideComparePanel();
});
function hideComparePanel() {
if (!list.length) {
$(".comparePan").empty();
$(".comparePanle").hide();
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有