我正在尝试构建一个小 jQuery 插件,但我收到 group.height() 不是函数的错误?
(function( $ ) {
$.fn.equalHeight = function(group) {
group = $.extend(group);
var tallest = 0;
group.each(function () {
var thisHeight = $(this).height();
if (thisHeight > tallest) {
tallest = thisHeight;
}
});
group.height(tallest);
// allow jQuery chaining
return this;
};
}( jQuery ));
用法示例如下:
<script>
// Usage example:
$( ".boxes section.box" ).equalHeight();
</script>