0

i have two div blocks in my code

1. <div class="for-devices">

    //some additional elements

   </div>

2. <div class="for-desktops">

     //some additional elements

   </div>

my question is what is the best way to show .for-devices div for devices and .for-desktops for desktops. If we access page from devices .for-desktop div should be removed and if we access page from desktops .for-devices should be removed.

anand
  • 502
  • 6
  • 9

1 Answers1

1
var UserAgent = navigator.userAgent.toLowerCase();

function DetectDevice()
{
   if (UserAgent.search("ipad") > -1 || UserAgent.search("iphone") > -1 || UserAgent.search("android") > -1){
      // Code for above devices
   }
}

DetectDevice();
Rohit Batham
  • 1,238
  • 1
  • 9
  • 13