So, if I correctly understood your question, you want to REMOVE it, right?
If so, then .remove()
goes right. It completely removes an element so you never can restore it (until refresh, of course).
But using .hide()
hides an element, like the display:none
does it. In that case an element still exists, but not visible to user. I am not sure if Google can pay you for this kind of "ad views", but it definitely breaks their rules.
So, for deleting reasons your code sample is best. But it may not be reversed.
If you still want to show this content later, but also want to prevent it from appearing on the page, the solution I see for this is to save that div
element to a variable, then remove element. Later you could restore it from the same variable. Like this:
$(document).ready(function(){
if ($('.back').is(":visible") == true) {
var bannerAd = $( "#bannerad" ).html();
$( "#bannerad" ).remove();
}
function showAdContent(bannerAd) {
$( "#bannerAd" ).text( bannerAd );
}
});
Guess it works.