This function only works when the page gets reloaded:
if (window.matchMedia("(max-width: 700px)").matches) {
$("html").css("background-color", "yellow");
} else {
$("html").css("background-color", "red");
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
But how can I additionally update it if the window size changes?
This article didn't help me so far. It's hard for me to find the best solution.