How to replace css using jquery after user agent detection


Tags: javascript,jquery,css

Problem :

I found this code to detect android native browser:

var nua = navigator.userAgent;
var is_android = ((nua.indexOf('Mozilla/5.0') > -1 && nua.indexOf('Android ') > -1 &&     nua.indexOf('AppleWebKit') > -1) && !(nua.indexOf('Chrome') > -1));

but how can I create function to repleace css after detection?

I know I should use something like that:

$('jQuery selector').css({"css property name":"css property value"});

but I don't now how :(

On the same page is other function that is using jquery.



Solution :

var nua = navigator.userAgent;
var is_android = ((nua.indexOf('Mozilla/5.0') > -1 && nua.indexOf('Android ') > -1 &&     nua.indexOf('AppleWebKit') > -1) && !(nua.indexOf('Chrome') > -1));

if (is_android){
  //for eg you want to remove border of a div with id #container
  $('#container').css({"border":"none"});
  //Best is to have a class created in css with which ever property you want to remove
  // if the class was .green-color
  $('#container').removeClass('green-color');
}

    CSS Howto..

    How to style the arrow that opens submenus in jQuery mmenu?

    The input fields do not have the same width. How to resolve this CSS challenge?

    How can I use a non-breaking space before an inline-block-default element, such as a

    How to make an Image overlay the site on click?

    How to improve the way I use Textmate for Ruby on Rails, HTML, CSS and Javascript?

    How to align div to the bottom of another div in HTML?

    How to disable css Animation keyframes in opera?

    How to make element sizes to fill cell sizes and increase font in free jqgrid inline and form editing

    How to stretch items in menu (from right to left) - HTML and CSS

    How to disable animation in a specific element in CSS

    How to get smooth Google fonts?

    How to change only one function of CSS transform property w/ multiple functions?

    How to add pixels to a current position of an element?

    How to implement z-index and overflow

    How to resize dynamic images coming from database in a responsive bootstrap website

    How to make an inline-block box stick to the top? [duplicate]

    Newbie: How to have a row background in my case?

    How to remove margin space around body or clear default css styles

    How to dynamically apply nested base languages in textarea?

    How to merge .CSS files with Sass (or other tool)? [duplicate]

    How to make css flex box row auto resizing horizontally with image

    How to put CSS and HTML in one page of code? [duplicate]

    How table-cell width with percentage value works?

    How to switch css table-cell from left to right?

    How to override w3.css for table border

    How to implement ::ms-clear in CSS?

    How to make an element remain inline

    How can I fix this Bootstrap layout issue?

    how to change inline css to free attributes

    How to make a css 'snail'?