Answer the question
In order to leave comments, you need to log in
How to select elements in jQuery?
Let's say we have this markup
<div class='a'>
<ul>
<li>высота1</li>
<li>высота2</li>
<li>высота3</li>
</ul>
</div>
<div class='a'>
<ul>
<li>высота4</li>
<li>высота5</li>
<li>высота6</li>
</ul>
</div>
var A = $('.a li'), max = 0, elem;
A.each(function() {
if (this.offsetWidth > max)
max = this.offsetWidth, elem = this;
});
Answer the question
In order to leave comments, you need to log in
$('.a').each(function () {
var max = 0;
$(this).find('li')
.each(function () {
if (this.offsetHeight > max) {
max = this.offsetHeight;
}
})
.css({
height: max + 'px'
});
});
var maxHeight = 0;
$('li').each(function() {
var $this = $(this);
$this.each(function() {
var height = $(this).height();
if (height > maxHeight) {
maxHeight = height;
}
});
});
$('li').height(maxHeight);
Maybe he messed up something there, wrote without checking. But it's like the idea itself is that you need to do 2 cycles.
$('.a').each(function(){
var max = 0;
$('li', this).each(function(){
if (this.offsetWidth > max)
max = this.offsetWidth
})
});
jQuery is not needed here, bare javascript will sufficenew URLSearchParams(location.search).get('v')
Is it possible to make the code work more optimized?
Here I wrote.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question