निम्नलिखित jQuery प्लगइन परिणाम सूचित करेंगे।
सीएसएस
#tempDiv{
height:10px;
overflow:hidden;
}
चौड़ाई में अतिप्रवाह निर्धारित करने के लिए,
(function($) {
$.fn.isOverflowWidth = function() {
return this.each(function() {
var el = $(this);
if (el.css("overflow") == "hidden") {
var text = el.html();
var t = $(this.cloneNode(true)).hide().css('position', 'absolute').css('overflow', 'visible').width('auto').height(el.height());
el.after(t);
function width() {
return t.width() > el.width();
};
alert(width());
}
});
};
})(jQuery);
ऊंचाई में अतिप्रवाह निर्धारित करने के लिए,
(function($) {
$.fn.isOverflowHeight = function() {
return this.each(function() {
var el = $(this);
if (el.css("overflow") == "hidden") {
var text = el.html();
var t = $(this.cloneNode(true)).hide().css('position', 'absolute').css('overflow', 'visible').height('auto').width(el.width());
el.after(t);
function height() {
return t.height() > el.height();
};
alert(height());
}
});
};
})(jQuery);
http://jsfiddle.net/C3hTV/
स्रोत
2011-08-21 14:49:07
वास्तव में "पता लगाने" का क्या मतलब है? प्रतिक्रिया में आप क्या करना चाहते हैं, स्क्रॉलबार दिखाएं? –
यदि टेक्स्ट ओवरफ्लो हो जाता है तो मैं माउस होवर पर div का आकार बदलना चाहता हूं लेकिन मैंने पहले से ही इसे हल किया है, इसलिए यह प्रश्न का हिस्सा नहीं था। –
महान उत्तर के साथ इसी तरह का पुराना प्रश्न: https://stackoverflow.com/a/143889/573057 – earcam