Last active
March 13, 2020 16:23
-
-
Save directionforward/57390e9ff5da42c019e6d54a99b4fa2e to your computer and use it in GitHub Desktop.
jQuery function to get width and height of SVG elements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* .widthSVG(className) | |
* Get the current computed width for the first element in the set of matched SVG elements. | |
*/ | |
$.fn.widthSVG = function(){ | |
return ($(this).get(0)) ? $(this).get(0).getBBox().width : null; | |
}; | |
/* | |
* .heightSVG(className) | |
* Get the current computed height for the first element in the set of matched SVG elements. | |
*/ | |
$.fn.heightSVG = function(){ | |
return ($(this).get(0)) ? $(this).get(0).getBBox().height : null; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment