Answer the question
In order to leave comments, you need to log in
HTMLcollection how to pull out a separate DIV?
There is such a function. I get a DIV from it with the fieled ID. And I need to change its width height depending on other divs.
function init() {
let LeftCornerInitContent = getCoords(document.getElementById(`${structuresHTMLAndCoordinats[0].item}`));
let RightCornerInitContent = getCoords(
document.getElementById(`${structuresHTMLAndCoordinats[structuresHTMLAndCoordinats.length - 1].item}`)
);
let rootObj = document.getElementById('fieled');
let ofsetResultOne = LeftCornerInitContent.right - RightCornerInitContent.left + 'px';
let ofsetResultTwo = LeftCornerInitContent.bottom - RightCornerInitContent.top + 'px';
if (rootObj && LeftCornerInitContent && RightCornerInitContent) {
rootObj.style.width = ofsetResultOne;
rootObj.style.height = ofsetResultTwo;
console.log(rootObj);
} else {
init();
}
// console.log(rootObj.style.width)
}
init();
rootObj.style.width = ofsetResultOne;
rootObj.style.height = ofsetResultTwo;
Answer the question
In order to leave comments, you need to log in
But when I receive it, I get, not only this div. And also the chilldllist of the divs nested in it.No, you don't. The getElementById function always returns one element if found.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question