Add css using jQuery

you can use the css() method. This method allows you to set one or more CSS properties for a selected element.

css() method add inline style on element, so I prefer addClass method instead of css method.

$('#content').css('background-color', #0162c9);

Add multiple css using jquery

$('#content').css({
  'background-color': '#000',
  'color': '#fff',
  'font-size': '20px'
});

See the Pen Add css using jQuery by Nirbhay (@nirbhaysingh) on CodePen.

No comments :

Please Give Your Feedback