in Education by

I have the access to this DOM node in temp1.$el. And here is the content which the above variable has:

Header1 Name
Header2 Name
Row1 Column1 Value
Row1 Column2 Value
I'm working in plain JavaScript and what I need to get is the width of the element under: table thead tr th (child-1) table thead tr th (child-2) I tried many things like: temp1.$el.tHead.firstElementChild.children[0].offsetWidth temp1.$el.tHead.firstElementChild.children[0].clientWidth temp1.$el.tHead.firstElementChild.children[0].firstElementChild.offsetWidth temp1.$el.tHead.firstElementChild.children[0].firstElementChild.clientWidth But all of them are not working. The table thead tr th widths depends of the actual content inside of them, and I need to take the widths and later to apply them on a different table. I managed to get them to the variable temp1.$el but from here, I'm not able to success to get the widths that I need. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

Please log in or register to answer this question.

1 Answer

0 votes
by

You could get this done using the ParentNode property children. The ParentNode property children is a read-only property that returns a live HTMLCollection which contains all of the child elements of the node upon which it was called. var element = document.getElementById('__BVID__730'); console.log(element.tHead.children[0].children[0].offsetWidth)

Header1 Name
Header2 Name
Row1 Column1 Value
Row1 Column2 Value
Run code snippetExpand snippet

Related questions

...