How to show a block only desktop or mobile devices?

Good day!
Guys, there is a problem.
There are two ad unit adsdesktop and adsmobile.
When the site went from the computer you want to display adsdesktop and hide adsmobile.
When I went from a mobile device, Vice versa.

Could you tell me the solution how to implement it? Maybe under WP there are plugins for these things?

The network found this code that fits-whether he and how to apply it?
<script type="text/javascript"> 
 var mobile = (/iphone|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())); 
 if (mobile) { 
 alert("Mobile device!!");
 $('.navWrap').css('display', 'none'); // or $('.navWrap').hide();
 } 
 else 
 { 
 alert("mobile device!"); 
}
</script>
July 2nd 19 at 13:17
1 answer
July 2nd 19 at 13:19
@media (max-width: 768px) {
. adsdesktop {
 display: none;
}
. adsmobile {
display: block;
}
}
https://developer.mozilla.org/en-US/docs/Web/CSS/M... - nasir28 commented on July 2nd 19 at 13:22
: Resolution it may be Full but the screen is not full and the window size of the browser is also not full - Dalton57 commented on July 2nd 19 at 13:25
: https://itmages.ru/image/view/5256244/449b7fd8 - Dalton57 commented on July 2nd 19 at 13:28
:
document.addEventListener('DOMContentLoaded', ()=>{
 'use strict';
 let doc = document,
 html = [],
 info = ['scr', 'wnd'];
 html.push('<div class="info"></div>');
doc.body.innerHTML=html.join(");
 html = [];
 for (let i =0; i<=1; i++){
 html.push('<div id="'+ info[i] + '"></div>' );
 doc.querySelector('.info').innerHTML = html.join(");

}
wnd();
 doc.querySelector('.info').style.cssText = 'background:rgba(0,0,0,.5);color:#fff;width:190px;padding:15px 25px;font-family:\'Open Sans\',sans-serif;font-size:12px;';
 window.addEventListener('resize', wnd);
 function wnd(){
 doc.querySelector('#scr').innerHTML = 'screen resolution:' + screen.width + ' x ' + screen.height + 'px';
 doc.querySelector('#wnd').innerHTML = 'window size:' + window.innerWidth + ' x ' + window.innerHeight + 'px';
};
});
- Dalton57 commented on July 2nd 19 at 13:31
: sketchapp.me/podrobno-o-density-pikselej-v-dizaj... - Dalton57 commented on July 2nd 19 at 13:34
why not give a very even give - Dalton57 commented on July 2nd 19 at 13:37
there is meaning in the fact that mobile devices and generally any retina and other screens there is such a thing as gravity and then there's the iPhone for example 640×1136 and density 2x ie pixel takes as much as 4 pixels, we get the actual size of 320 by 568 and on this screen is a condition (max-width: 768px) is even going to work - Dalton57 commented on July 2nd 19 at 13:40
: Yes condition written for desktops - Dalton57 commented on July 2nd 19 at 13:43
: it's not the iPhones and screens - Dalton57 commented on July 2nd 19 at 13:46
: what's not junk? - Dalton57 commented on July 2nd 19 at 13:49
: and Chale on the screen and so well, it's at least not professionally there is a zoo screens and there's no escape - Dalton57 commented on July 2nd 19 at 13:52
:
I have a tablet generates css in the screen 1300 1200

And please tell us what kind of tablet computers and shows that this a test?
https://www.esolutions.se/en-GB/test - Elmer.Upt commented on July 2nd 19 at 13:55
: Yes, it had most likely viewport is not registered or it measures something ) - Dalton57 commented on July 2nd 19 at 13:58
: well, I think so too, but check something like - Elmer.Upt commented on July 2nd 19 at 14:01

Find more questions by tags JavaScriptCSS