jQuery找出网页上最高元素的方法


本文实例讲述了jQuery找出网页上最高元素的方法。分享给大家供大家参考。具体如下:

这段JS代码通过jQuery遍历网页上的元素,找出其中最高的元素

$(document).ready(function() {
  var maxHeight = -1;
  $('.features').each(function() {
   maxHeight = maxHeight > $(this).height() ? maxHeight : $(this).height();
  });
  $('.features').each(function() {
   $(this).height(maxHeight);
  });
});

希望本文所述对大家的jQuery程序设计有所帮助。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3