Computer Magic Logo
Add class depending on browser

Friday, January 22, 2016

Published by Aristotelis Pitaridis

Sometimes we want to have different class assigned to an element depending on the browser the user uses in order to visit our page. The code below demonstrates how to add the class name to all the div elements.

$(function() {
    $('div').addClass($.browser);
});