0

Say I want to set a style to a class, I would do this:

$head.append('<style>.class1{color:red}</style>');

However, is there any way that I can set it without adding <style> tags? Is there anything like this:

$('.class1').addStyle('color','red');

I know people would use

$('.class1').css('color','red');

But this would only update the created elements. It's not gonna apply to those newly created .class1 elements.

AGamePlayer
  • 7,404
  • 19
  • 62
  • 119
  • The method that you've mentioned is probably the easiest way because, otherwise, you'll have to go through all the style sheets to find all the definitions for the class and modify them, there is a similar question out there https://stackoverflow.com/q/10643495/1552587 – Titus Dec 22 '19 at 07:07
  • The method does exist? – AGamePlayer Dec 22 '19 at 07:29
  • I mean the appending of a style element to the ``, that method. – Titus Dec 22 '19 at 07:31

0 Answers0