0

I need to compare two blocks and assign greater importance to the height main div, BUT IT SHOULD BE EVEN.

<div class="main-content">
<div class="content-1"></div>
<div class="content-2"></div>
</div>

JS:

var
  $content1 = $('.md-content .content-1');
  $content2 = $('.md-content .content-2');

c = ($content2.height() > $content1.height()) ? $content2.height() : $content1.height();
$('.md-content .tabs .content').height(c);

// set even
    var
        modal = $('.md-content .content');
    if (modal.height() % 2 != 0) { modal.css({ 'height': modal.height() + 1 }); }
    else { modal.css({ 'height': modal.height() + 0 }); }

I want to know how to make it more convenient.

Noth Wild
  • 11
  • 2
  • 4

1 Answers1

0

What do you mean "assign greater importance to the height main div"? If you want to make .content-1 and .content-2 the height of .main-content, you can just use JS.

jQuery:

$('.content-1, .content-2').height( $('.main-content').height() );

Vanilla JS:

var x = document.getElementsByClassName("content-1 content-2");
x.style.height = document.getElementsByClassName("main-content").clientHeight;
Rhecil Codes
  • 511
  • 4
  • 24