var bbox = textElement.getBBox();
var width = bbox.width;
var height = bbox.height;
and then set the rect’s attributes accordingly.
Link: getBBox()
in the SVG v1.1 standard.
More Related Contents:
- Finding line-wraps
- JavaScript accessing inner DOM of SVG
- How to check if an embedded SVG document is loaded in an html page?
- Add SVG element to existing SVG using DOM
- Is it possible to use HTML’s .querySelector() to select by xlink attribute in an SVG?
- Is there a flexible way to modify the contents of an editable element?
- Accessing a DOM object defined in an external SVG file
- draw text in d3 arc javascript
- How do I manipulate the SVG DOM and create elements?
- Create a table in SVG
- When should I use jQuery’s document.ready function?
- Create SVG tag with JavaScript
- How do I replace text inside a div element?
- How to bind bootstrap popover on dynamic elements
- getElementsByName in IE7
- JavaScript: DOM load events, execution sequence, and $(document).ready()
- Difference between .tagName and .nodeName
- Hit-testing SVG shapes?
- HTML Table with vertical rows
- Getting selected text position
- How to start an animated SVG on entering viewport?
- Is it the last `script` element the currently running script?
- How to generate unique css selector for DOM element?
- React, losing saved data in localStorage with useEffect after page refresh
- Stopping a iframe from loading a page using javascript
- Boolean HTML Attributes
- Rasterizing an in-document SVG to Canvas
- How to add a onclick event to an element using javascript
- Test if an element can contain text
- Screen Coordinates of a element, via Javascript