There are no errors when i do resize() into console with this code, and the the box resizes it's height to it's width.
function resize() {
let box = document.getElementById("id");
let width = $("#id").width();
box.style.height = width;
}
I want to do that automatically so i just tried adding resize(); in the end of the js file like this:
function resize() {
let box = document.getElementById("id");
let width = $("#id").width();
box.style.height = width;
}
resize();
But nothing happens and there is an error in the console:
Uncaught TypeError: Cannot read property 'style' of null
at resize (main.js:4)
at main.js:7
resize @ main.js:4
(anonymous) @ main.js:7