I have to resize div elements using javascript . I have this code -
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>home page</title>
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="bootstrapCSS/bootstrap.css">
</head>
<body>
<div class="container">
<div id="column1" class="column">left</div>
<div id="column2" class="column">middle</div>
<div id="column3" class="column">right</div>
<script>
var columns = document.getElementsByClassName("column");
var displaysize = window.innerWidth;
window.onresize = function () {
for (const column of columns) {
if (window.innerWidth < 560) {
column.style.display = "block";
}
else {
column.style.display = "inline-block";
}
}
}
</script>
</div>
</body>
</html>
Scripts here are working correctly, But when using displaysize variable in the if statement the function is not working. So, what is the problem with this code.
Edit
Even this is not working when function is named like function resizer(),then calling on the event