From 43f1ffb073537508e94a9a4928d9334621cc615c Mon Sep 17 00:00:00 2001 From: whut Date: Fri, 21 Oct 2011 14:47:37 +0200 Subject: [PATCH] Added fix for using watermark inside some element with display:none For example when using watermark on text input that is inside div with display:none, watermark will be shown too high, because at the moment of calculating style for watermark, input height was 0, but outerHeight was 4 --- jquery.watermark.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jquery.watermark.js b/jquery.watermark.js index 09d846a..9a577b8 100644 --- a/jquery.watermark.js +++ b/jquery.watermark.js @@ -90,12 +90,16 @@ e_top = ($elem.css('padding-top') != 'auto' ? parseInt($elem.css('padding-top')):0); }else{ e_height = $elem.outerHeight(); - if(e_height <= 0) + if(e_height <= 0 || $elem.height() <= 0) { e_height = ($elem.css('padding-top') != 'auto' ? parseInt($elem.css('padding-top')):0); e_height += ($elem.css('padding-bottom') != 'auto' ? parseInt($elem.css('padding-bottom')):0); e_height += ($elem.css('height') != 'auto' ? parseInt($elem.css('height')):0); } + + if (e_height <= 0) { + e_height = $elem.css('line-height'); + } } e_top += ($elem.css('margin-top') != 'auto' ? parseInt($elem.css('margin-top')):0);