How To Define Multiple CSS Attributes In JQuery

For More Videos Visit Our YouTube Channel




Here we consider how to define multiple css attributes in jQuery. Lets start with one example here. Suppose we have a Div with particular height and width.

How To Define Multiple CSS Attributes In JQuery, Define Multiple CSS Attributes In JQuery, Define Multiple CSS Attributes, Multiple CSS Styles In JQuery, Multiple CSS Styles In JavaScript, jQuery add styles, jQuery add multiple styles, multiple style, Multiple CSS Attributes, jQuery, HTML, php

We needs to add background color and border to this Div. In jQuery, we can use css function for adding style. For adding multiple styles, the best way is to define a class inside Style section.

Add required styles inside this Class. Here we declare a class named newStyle inside Style section. We have added background color as red and Border of 4px.

.newStyle {
         background: red;
         border :4px solid black;
}



Now use jQuery addClass for adding this class to the Div.

$(function () {
         $('#divID').addClass('newStyle');
});



That's all, by this way we can add multiple style using jQuery.