I am trying to return / output the largest Height value out of multiple divs within an alert using jQuery or JavaScript. I’ve tried a few examples but I think I’m going about it the wrong way. I decided to use Math.max but I think that incorrect.
My code
$(".go-buttn").click(function(){
var sum = 0;
var x = document.querySelectorAll(".col-lg-6.col-md-12.col-sm-12 .block");
var maxValueInArray = Math.max.apply(Math, x);
alert($(maxValueInArray).height());
});
<button class="go-button">Click me </button>
<div> //This first div should return the tallest value in height
<p>
test
</p>
<p>
test
</p>
<p>
test
</p>
</div>
<div>
<p>
Test
</p>
</div>
<div>
<p>
Test
</p>
</div>