I am using Spring MVC
and we are saving some styles directly in our database. There is no CSS file for these styles. Now my problem is that I have styling text like below:
.className {
background-color: red; color: blue;
}
.anotherClassName {
padding: 15px; margin: 10px;
}
I am aware of jQuery .css
method but its syntax is css("propertyname","value");
How can use my styling from jQuery?
CodePudding user response:
As simple as this...
const myCssString = `.className {
background-color: red; color: blue;
}
.anotherClassName {
padding: 15px; margin: 10px;
}`;
$('<style>', {
text: myCssString
}).appendTo('head');