Reputation: 371
I'm hoping to invert all the colors on the page on a button click, and I haven't learned to invert colors. Is there some way to achieve this with a jQuery or JS method, e.g:
$("#button").click(function() {
$(body).invert()
}
or do I have to go through the CSS method?
Thanks.
Upvotes: 1
Views: 1070
Reputation: 1271
Yes, you can do it with CSS:
body.invert {
filter: invert(1);
}
https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/invert
Just toggle class .invert
with JS click.
Upvotes: 3