Some day ago I had a cross browsing issue while I was working on a project. To resolve that problem I had to add a Class on the body tag to write additional CSS . But I did not know how to do that so I started Google and spend around three hours to find a solution. So here I am describing how do we add additional class to a HTML element using jQuery depending on Browser.


We will use jQuery broswer  property ($.broswer ) which is an array  of elements where we will get the browser name.

Lets have an Example:

If you run this code, you will get the browser name, its version and other information.

So now we just need to modify this code according to our need. For example we will need to add a Class on the body if the browser is Safari. Please check the below code….

So we just need to change the browser name with the key like if you want to add Class on the Chrome browser, you will need to write