B
B
balex7772020-04-28 13:21:31
JavaScript
balex777, 2020-04-28 13:21:31

How to calculate the width of an element down to hundredths of a pixel using js or jquery?

Hey, you need to get the width of an element using jquery. The element has this width of 202.45px, and $('selector').width(); gives the integer 202.
How to get 202.45?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
McBernar, 2020-04-28
@balex777

const element = document.getElementById('id')
const width = getComputedStyle(element).width

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question