How to disable all external CSS inside of a specific element using StyleSheet.disabled? Not sure if I’m just missing proper syntax. If it’s only possible at document level, is there any way I can implement something like this? Thank you.
HTML
<div id="container">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet">
<i class="material-icons">edit</i>
<button class="btn btn-primary">Bootstrap</button>
</div>
JS
let el = document.querySelectorAll('#container [rel="stylesheet"]');
for (let i = 0; i < el.length; i++) {
el.styleSheet[i].disabled = true;
}
Here’s a working example with document as default selector: JsFiddle
2
Answers
You can replace the
href
attribute with a customdata-href
attribute (as a placeholder) :I think you made a typo in your code:
Try this link: https://jsfiddle.net/p0v3rdac/