var list = [];
$(document).ready(function(){
$(".addToCompare").click(function(){
$(".comparePanle").show();
var productID = $(this).parents('.selectProduct').attr('data-title');
var display = document.getElementById("cm");
if(display.style.display = "none"){
document.getElementById("cm").style.display = "block";
}
list.push(productID);
var displayTitle = $(this).parents('.selectProduct').attr('data-title');
var displayPrize = $(this).parents('.selectProduct').attr('data-prize');
var image = $(".image").attr('src');
$(".comparePan").append(
'<div id="' + productID + '" style="font-size:15px "class="productPart titleMargin w3-margin-bottom w3-col l3 m4 s4"><div class="w3-white"><a class="selectedItemCloseBtn w3-closeBtn">X</a><img src="' + image + '"style="height:100px;"/><p id="' + productID + '" class="titleMargin1">' + displayTitle + '</p><p id="' + productID + '" class="titleMargin1">' + displayPrize + '</p></div></div>');
$(document).on('click','.selectedItemCloseBtn',function () {
$(this).parents(".productPart").remove();
if(!$(".productPart").length){
$(".comparePanle").hide();
}
});
});
$(".closeComparePanle").click(function(){
$(".productPart").remove();
$(".comparePanle").hide();
});
});
Mình xin cảm ơn ạ