Applying styles to selectors - insertRule()

0
Reputation

Taken from https://davidwalsh.name/essential-javascript-functions

"...we can grab a NodeList from a selector (via document.querySelectorAll) and give each of them a style, but what's more efficient is setting that style to a selector (like you do in a stylesheet)... This is especially useful when working on a dynamic, AJAX-heavy site. If you set the style to a selector, you don't need to account for styling each element that may match that selector (now or in the future)."

Version:



                            
    Kyle

    Kyle

    OneLib developer/administrator
    There is 1 person using this snippet in their library: