平板电脑或手机中的show popunder出错

In my template I include a tool to show a pop-under when it is in tablet devices and other pop-under when it is other devices( cellphone, desktop,etc ) I tested and work perfect with banner, but when I try to use pop-under does not work, and I don';t know how fix it, If somebody can help me, thanks..

 }
        if(is_tablet==1) {
            $("#tablet-ad-space").show();
            $("#mobile-ad-space").remove();
        }
        else {
            $("#tablet-ad-space").remove();
            $("#mobile-ad-space").show();       
        }           

Use hide() function insted of remove() because remove() remove element from DOM.