Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get css width of class?

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

like image 794
Faraona Avatar asked Apr 30 '11 12:04

Faraona


1 Answers

The easiest way is probably to ignore that <div>, create a new one with the class you care about and check its style attributes. You need to add it to the DOM for it to adopt the CSS of the document.

var div = $('<div>').addClass('css-1').hide();
$('body').append(div);
var width = div.css('width');
div.remove();
like image 135
Samir Talwar Avatar answered Sep 20 '22 12:09

Samir Talwar