10 examples of 'get width of element javascript' in JavaScript

Every line of 'get width of element javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
63getSizeElementWidth()
64{
65 // console.log("Width : element:",this.element[0].Width);
66 // console.log("offsetWidth : element:",this.element[0].offsetWidth);
67 return this.element[0].offsetWidth;
68}
162_get_width: function _get_width($el) {
163 return $el.width() + parseInt($el.css("padding-left")) + parseInt($el.css("margin-left")) + parseInt($el.css("padding-right")) + parseInt($el.css("margin-right"));
164},
10export function getElementWidth (element: HTMLElement): number {
11 const { width, paddingLeft, paddingRight } = window.getComputedStyle(element)
12 const computedWidth = Number(width)
13
14 if (!Number.isNaN(computedWidth)) {
15 return computedWidth
16 }
17
18 const computedPaddingLeft = paddingLeft ? Number.parseInt(paddingLeft, 10) : 0
19 const computedPaddingRight = paddingRight ? Number.parseInt(paddingRight, 10) : 0
20
21 return element.offsetWidth - computedPaddingLeft - computedPaddingRight
22}
129function get_width(obj) {
130 return typeof obj == 'object' && obj && obj.width != undefined
131 ? obj.width
132 : ((typeof obj == 'object' && obj !== null ? utils.strlen(obj.text) : utils.strlen(obj)) + (style['padding-left'] || 0) + (style['padding-right'] || 0))
133}
27function getWidth(id)
28{
29 return getComputedStyleForElement(document.getElementById(id), 'width');
30}
6export function getInnerWidth(element: any): number {
7 const cs: any = window.getComputedStyle(element);
8 return (
9 element.offsetWidth -
10 (parseFloat(cs.paddingLeft) +
11 parseFloat(cs.paddingRight) +
12 parseFloat(cs.borderLeftWidth) +
13 parseFloat(cs.borderRightWidth))
14 );
15}
8function getInnerWidth(element) {
9 const cs = window.getComputedStyle(element);
10 return (element.offsetWidth -
11 (parseFloat(cs.paddingLeft) +
12 parseFloat(cs.paddingRight) +
13 parseFloat(cs.borderLeftWidth) +
14 parseFloat(cs.borderRightWidth)));
15}
166get_width() {
167 var w = this.props.widget.width;
168 return w * this.props.gw / 12;
169}
24function getWidth(object) {
25 var clone = object.clone();
26
27 clone.css({
28 position: 'absolute',
29 visibility: 'hidden',
30 display: 'inline-block'
31 });
32
33 $(document.body).append(clone);
34 var width = clone.width();
35
36 clone.remove();
37
38 return width;
39}
152getWidth() {
153 return $(this.dom).outerWidth();
154}

Related snippets