dhtmlx - get width of a div which was generated by javascript on runtime -
I have some columns that were generated from dhtmlx javascript. Column was generated at run-time which means that if I tried to see the source code of the page using Chrome's View page Tire, I would not be able to see the generated code. But I can right-click on the element to see the generated code and 'inspect the element' is a part of the code generated here, which I paste with 'applying elements':
& Lt; Div id = "scheduler_here" class = "dhx_cal_container dhx_scheduler_grid" style = "width: 100%; height: 100%;" & gt; & Lt; Div class = "dhx_cal_header" style = "width: 1148 px; height: 20px; left: -1px; top: 60px;" & Gt; & Lt; Div class = "dhx_grid_line" & gt; & Lt; Div style = "width: 16 9px;" & Gt; Start date & lt; / Div & gt; & Lt; Div style = "width: 16 9px;" & Gt; Time & lt; / Div & gt; & Lt; Div style = "width: 16 9px;" & Gt; Event & lt; / Div & gt; & Lt; Div style = "width: 16 9px;" & Gt; Location & lt; / Div & gt; & Lt; Div style = "width: 16 9px;" & Gt; Stakeholder & lt; / Div & gt; & Lt; Div style = "width: 16 9px;" & Gt; Type & lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "dhx_cal_data" style = "width: 1148 px; height: 506px; left: 0px; top: 81px; overflow-wi: auto;" & Gt; & Lt; Div & gt; & Lt; Div class = "dhx_grid_v_border" style = "left: 184px" id = "imincol0" & gt; & Lt; / Div & gt; & Lt; Div class = "dhx_grid_v_border" style = "left: 370px" id = "imincol1" & gt; & Lt; / Div & gt; & Lt; Div class = "dhx_grid_v_border" style = "left: 556px" id = "imincol2" & gt; & Lt; / Div & gt; & Lt; Div class = "dhx_grid_v_border" style = "left: 742px" id = "imincol3" & gt; & Lt; / Div & gt; & Lt; Div class = "dhx_grid_v_border" style = "left: 928px" id = "imincol4" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "dhx_grid_area" & gt; & Lt; Table & gt; & Lt; / Table & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; I am trying to get the width of the column of imincol0, imincol1, imincol2 and on which you can see on the last part of the code. I tried some methods to get the width of the columns with these methods but there is no benefit. I always get zero.
If you use jquery, you can:
Var x = $ ('# imincol0'). Width ();
If you are using pure JS then you can try it: var x = document.getElementById ('imincol0'). OffsetWidth;
Comments
Post a Comment