Skip to content

Instantly share code, notes, and snippets.

@lutzissler
Created October 14, 2013 12:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lutzissler/6975084 to your computer and use it in GitHub Desktop.
Save lutzissler/6975084 to your computer and use it in GitHub Desktop.
jQuery realWidth plugin. Returns the real (sub-pixel, non-rounded) width of an element as stored internally in the browser. Thanks to ssorallen for the hint. See http://stackoverflow.com/questions/3603065/do-not-round-width-in-jquery#16072668 for context.
(function ($) {
$.fn.realWidth = function () {
var els = $(this);
return els.length ? els[0].getBoundingClientRect().width : null;
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment