jQuery: How to calculate the maximal attribute value of all matched elements?

后端 未结 6 839
悲哀的现实
悲哀的现实 2020-12-01 20:57

Consider the following HTML:

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 21:41

    var max =0;
    $('.a').each(function(){
    
        if(parseFloat($(this).attr('x'))>max)
        {
             max = parseFloat($(this).attr('x')) ;
        }
    });
    
    alert(max);
    

提交回复
热议问题