Please take a look at this fiddle
Is this how you would put an if statement in a hover function?
$( ".nn" ).hover(
function() {
if($(this).find('p').height() > $(this).height())
{
$( this ).css( "height","auto" ).removeClass("oh");
}
}, function() {
$( this ).css( "height","6em" ).addClass("oh");
}
);
Since the if statement is only for the first function (mouseover), does the function still trigger on the mouseout function? Is it possible to wrap the if statement around the entire hover function,something like this:
$( ".nn" ).hover(
function() {
if($(this).find('p').height() > $(this).height())
{
$( this ).css( "height","auto" ).removeClass("oh");
}, function() {
$( this ).css( "height","6em" ).addClass("oh");
}
}
);
HTML
Very long text
<div class="nn oh"><p>short text</p></div>