I can display the contents of a function using functionName.toString()
Is is possible to display the contents of the <style></style> section?
Using XXX.toString(), like maybe: styleName.toString()?
Or something else?
I can't figure out how to reference the <style> contents.
CodePudding user response:
Use the innerHTML or innerText property, just like any other DOM element.
document.querySelector("style").innerText
If you have multiple <style> elements you can give the one you want an ID and use that in the selector. If you want all of them, you can use document.querySelectorAll("style") and loop over them.
