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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top