Skip to content

Commit 8f5f13f

Browse files
committed
added matchHeight('remove')
1 parent a3a058c commit 8f5f13f

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

jquery.matchHeight.js

+18
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@
77
(function($) {
88

99
$.fn.matchHeight = function(byRow) {
10+
11+
// handle matchHeight('remove')
12+
if (byRow === 'remove') {
13+
var that = this;
14+
15+
// remove fixed height from all selected elements
16+
this.css('height', '');
17+
18+
// remove selected elements from all groups
19+
$.each($.fn.matchHeight._groups, function(key, group) {
20+
group.elements = group.elements.not(that);
21+
});
22+
23+
// TODO: cleanup empty groups
24+
25+
return this;
26+
}
27+
1028
if (this.length <= 1)
1129
return this;
1230

test.css

+5
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ a, a:link, a:visited, a:active, a:hover {
6969
margin: 5px 20px 5px 0;
7070
}
7171

72+
.test-remove {
73+
padding: 5px;
74+
margin: -5px 20px;
75+
}
76+
7277
/* test items */
7378

7479
.items-container,

test.html

+12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
$('.items-container').each(function() {
2929
$(this).children('.item').matchHeight(byRow);
3030
});
31+
32+
// example of removing matchHeight
33+
$('.test-remove').click(function() {
34+
$('.items-container').each(function() {
35+
$(this).children('.item').matchHeight('remove');
36+
});
37+
});
3138
});
3239

3340
})();
@@ -77,6 +84,11 @@ <h1>jquery.matchHeight Tests</h1>
7784
by row
7885
</label>
7986
</div>
87+
<div class="checkbox">
88+
<label>
89+
<input class="test-remove" type="submit" value="remove all">
90+
</label>
91+
</div>
8092
</div>
8193

8294
<div class="items-container">

0 commit comments

Comments
 (0)