Question

I need to remove a div on mobile devices only - my site is responsive - and at the moment i am using css display:none; however i want it to be removed from the DOM completely.

The DIV has google adsense code inside and show is still "showing" up on mobile devices even though the advert does not show - and this is doubling the adverts pageviews and lowering the click through rate unnecessarily.

so how can you remove a DIV using jquery remove at a specific break point?

Was it helpful?

Solution

To do this using screen width:

if ($(window).width() < 797) {
  $('#youDiv').remove();
}

Change the 797 to whatever breakpoint you want and add your div id in.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top