var c = $('.needIco .p_list').html(); $('.mapIcon').append(c); $('.needIco .p_list').empty(); $('.shouTable').click(function () { $(this).next().slideToggle(); }); $('.mapIcon').on('click', 'div:not(.in)', function () { var text = $(this).find('p').text().trim(); var offset = $(this).offset(); var w = $(this).width(); var ww = $(window).width(); var il = ww - offset.left; var wid = 320; var zhi = ''; $(this).addClass('in').siblings().removeClass('in'); $('.summ .p_loopitem').each(function () { var compareText = $(this).find('.fText').text().trim(); if (compareText === text) { var cloned = $(this).clone(); function zhibox() { if (wid + 40 >= il) { zhi = offset.left - wid - w - 40; } else { zhi = offset.left; } } zhibox(); cloned.css({ position: 'absolute', top: offset.top - 20, left: zhi, width: wid }); $('.clonedMap').remove(); cloned.addClass('clonedMap'); // $('body').append(cloned); gsap.fromTo(cloned, { autoAlpha: 0, x: 30, y: 30 }, { autoAlpha: 1, y: 0, duration: 0.3 } ); } }); var itema = true; $('.clonedMap .p_item:first-child p:not(:first-child)').each(function () { if ($(this).text().trim() !== '') { itema = false; return false; } }); if (itema) { $('.clonedMap .p_item:first-child').attr('hidden', ''); } var itemb = true; $('.clonedMap .p_item:nth-child(2) span').each(function () { if ($(this).text().trim() !== '') { console.log($(this).text().trim()) itemb = false; return false; } }); if (itemb) { $('.clonedMap .p_item:nth-child(2)').attr('hidden', ''); } }) $('.mapIcon').on('click', 'div.in', function () { var text = $(this).find('p').text().trim(); $(this).removeClass('in'); $('body > .p_loopitem').each(function () { var compareText = $(this).find('.fText').text().trim(); if (compareText === text) { $(this).remove(); } }); }) $('.mapIcon').on('click', 'img', function () { $(this).siblings().removeClass('in'); $('body > .p_loopitem').remove(); });