Find out divs height and setting div height

后端 未结 9 933
天涯浪人
天涯浪人 2020-12-14 21:41

I\'m quite new to javascript/jquery stuff, but i would like to do this kind of thing with it:

I have four divs side-by-side like this and content in each one. Now if

9条回答
  •  感情败类
    2020-12-14 22:11

    This is simple code

    var heights = $("element").map(function ()
    {
        return $(this).height();
    }).get(),
    
    MaxHeight = Math.max.apply(null, heights);
    

    or

    var highest = null;
    var hi = 0;
    $(".testdiv").each(function(){
    var h = $(this).height();
    if(h > hi){
       hi = h;
     highest = $(this);  
     }    
    });
    
    highest.css("background-color", "red");
    

提交回复
热议问题