Okay so with much attempt to no prevail, I have been trying to change the order of the below divs using the following JScript command (without jQuery) only when the window is at a certain width; particularly 1024px and below. The JScript used is successful in executing and subsequently changing the order of the divs, however it occurs at all widths.
I wish for box-3 to be above box-1 when the window width is equal to or less than 1024px (without using jQuery).
<html>
<body>
<div class="box-1"></div>
<div class="box-2"></div>
<div class="box-3"></div>
<div class="box-4"></div>
</body>
</html>
<script type="text/javascript">
var content = document.querySelector('.box-3');
var parent = content.parentNode;
parent.insertBefore(content, parent.firstChild);
</script>
Thanks in advance!
Edit: Question is different from "Execute function based on screen size" (Authored by Jim) because solutions given to Jim included - and accepted - jQuery, whereas this question is purely for vanilla Javascript