function myFunction() {
document.getElementById('img');
const element = document.styleSheets[0].cssRules[0].style.removeProperty('content');
}
img {
content: url("https://static.vecteezy.com/system/resources/previews/005/476/277/original/under-18-forbidden-round-icon-sign-illustration-eighteen-or-older-persons-adult-content-18-plus-only-rating-isolated-on-white-background-free-vector.jpg");
max-width: 100%;
height: auto;
}
<button onclick="myFunction()">Show pics</button>
<img src="https://m.media-amazon.com/images/I/81K2hJBAduL.png">
The point is that after clicking on the "delete" button, the "content" property for the entire website.
2
Answers
@Rafal You’re only selecting the first instance of the stylesheet. It would help if you iterated through the stylesheet to remove all instances of the "content" property.
For example:
Your solution seems a little overengineered.
Consider this simplified solution: