` input.star:checked ~ label.star:before {
content: '\f005';
color: #FD4;
transition: all .25s;
} `
how can I apply this code by javascript ?
` input.star:checked ~ label.star:before {
content: '\f005';
color: #FD4;
transition: all .25s;
} `
how can I apply this code by javascript ?
If you want add a style with js, you can use the insertRule() of style.sheet, the example code:
var sheet = (function() {
// Create the <style> tag
var style = document.createElement("style");
// WebKit hack :(
style.appendChild(document.createTextNode(""));
// Add the <style> element to the page
document.head.appendChild(style);
return style.sheet;
})();
// for a test
sheet.insertRule("body { background-color:red;}", sheet.length);
// for your code just replace param
// sheet.insertRule("input.star:checked ~ label.star:before {content: '\f005';color: #FD4;transition: all .25s;}}", sheet.length);