How to get css class width?

My question is: how can I get the width parameter of the css class? For example, I have a <div class="page css-1" id="page1">div with id = pages and the classes "page" and "css-1". I want to get css-1 style width parameter ?

+5
source share
1 answer

The easiest way is to ignore this one <div>, create a new one with the class that interests you, and check its style attributes. You need to add it to the DOM so that it can use the CSS of the document.

var div = $('<div>').addClass('css-1').hide();
$('body').append(div);
var width = div.css('width');
div.remove();
+10
source

All Articles