How to add css depending on device like ipad, android, desktop etc ?
Solution:
jQuery(document).ready(function(){
var deviceAgent = navigator.userAgent.toLowerCase();
alert(deviceAgent);
if(deviceAgent.match(/android/i))
{
alert('android');
}
if(deviceAgent.match(/ipad/i))
{
jQuery('head').append("<link rel='stylesheet' href='android.css' type='text/css' />");
}
console.log(navigator.userAgent.toLowerCase());
})
Solution:
jQuery(document).ready(function(){
var deviceAgent = navigator.userAgent.toLowerCase();
alert(deviceAgent);
if(deviceAgent.match(/android/i))
{
alert('android');
}
if(deviceAgent.match(/ipad/i))
{
jQuery('head').append("<link rel='stylesheet' href='android.css' type='text/css' />");
}
console.log(navigator.userAgent.toLowerCase());
})
0 comments: