Reputation: 68680
$.fn.findMaxHeight = function() {
var wrapperHeight = $(this).height();
var wrapperMaxHeight = $(this).css('max-height');
if ( wrapperHeight == wrapperMaxHeight ) {
alert("max-height reached");
} else {
alert("not yet");
}
}
$('.subscription-wrapper').findMaxHeight();
$('.payment-wrapper').findMaxHeight();
... doesn't work because .css()
returns 300px
and .height()
returns 300
so they can't be compared. how do I fix it?
Upvotes: 0
Views: 45
Reputation: 3631
Just use parseInt
.
Specifically,
var wrapperMaxHeight = parseInt($(this).css('max-height'), 10);
Upvotes: 4
Reputation: 21300
Use parseFloat instead of parseInt. The height is not always an integer! Half-pixels are possible.
Upvotes: 0
Reputation: 14025
Convert your CSS height using parseInt
var wrapperMaxHeight = parseInt($(this).css('max-height'));
Upvotes: 0