JS实现商品添加2级规格
规格容器
点击“添加规格”弹出规格代码层
function addSpecLev()
{
spec_count+=1;
let doms='
'$(".add-spec-other").before(doms);
}
添加规格
function addSpec(specCount)
{
let doms='
'$(".add-spec-"+specCount).before(doms);
}
移除一行规格,当移除所有规格行后自动移除当前级规格
function removeSpec(obj)
{
let topParent=$(obj).parent().parent().parent();
let listParent=$(obj).parent().parent();
let childs=$(topParent).children().length;
console.log(childs)
listParent.remove();
if(childs==3) {
topParent.remove();
}
}