Getting div width with parent display: none in jQuery Tab Control

I have a jquery tab control in which I create a custom control that I created that needs to know its width during the build process.

My problem is when you put in the parent container, in this case the tab that has β€œdisplay: none”, I cannot calculate the width.

I tried this in both directions:

$('.DataRow').width()
$('.DataRow').css('width')

both return 0.

Is there any other way to get the value of this width?

+3
source share
2 answers

visibility: hidden. , visibility:hidden, display:none. , display:none -, "" DOM.

:

<div id="parent" style="display: none">
    <div> find my width </div>
</div>

:

$('#parent').css('visibility', 'hidden').show();
var w = $('#parent div').width();
$('#parent').css('visibility', 'visible').hide();
console.log('width: ', w);

:

> width:  496

Update:

jQuery UI - :

$('#tabs-3').css('visibility', 'hidden').removeClass('ui-tabs-hide');

'#tabs-3' - . . .

+4

, theres ' , :

$('.DataRow').show(); //show it
var w = $('.DataRow').width()  //get the width
$('.DataRow').hide(); //hide it

, . (, / ) , - , , , .

-1

All Articles