To improve efficiency, it is recommended to utilize the parseInt
function. The jQuery methods .width()
and .height()
are also effective in this context.
Furthermore, creating separate functions for fetching these values would be beneficial:
.minHeight()
, .minHeight( size )
, .minHeight( function() )
.maxHeight()
, ...
.minWidth()
, ...
.maxWidth()
, ...
Example implementation:
(function($, undefined) {
var oldPlugins = {};
$.each([ "min", "max" ], function(_, name) {
$.each([ "Width", "Height" ], function(_, dimension) {
var type = name + dimension,
cssProperty = [name, dimension.toLowerCase()].join('-');
oldPlugins[ type ] = $.fn[ type ];
$.fn[ type ] = function(size) {
var elem = this[0];
if (!elem) {
return !size ? null : this;
}
if ($.isFunction(size)) {
return this.each(function(i) {
var $self = $(this);
$self[ type ](size.call(this, i, $self[ type ]()));
});
}
if (size === undefined) {
var orig = $.css(elem, cssProperty),
ret = parseFloat(orig);
return jQuery.isNaN(ret) ? orig : ret;
} else {
return this.css(cssProperty, typeof size === "string" ? size : size + "px");
}
};
});
});
})(jQuery);
Your code can then be simplified as shown below:
alert($('#<%=lstProcessName.ClientID%>').parent('.column4').width());
alert($('#<%=lstProcessName.ClientID%>').parent('.column4').minWidth());
alert($('#<%=lstProcessName.ClientID%>').parent('.column4').width() >= $('#<%=lstProcessName.ClientID%>').parent('.column4').minWidth());
if ($('#<%=lstProcessName.ClientID%>').parent('.column4').width() >= $('#<%=lstProcessName.ClientID%>').parent('.column4').minWidth()) {