This package has been deprecated

Author message:

This package has been deprecated

@saekitominaga/htmlelement-text
TypeScript icon, indicating that this package has built-in type declarations

1.2.6 • Public • Published

Get the text width (width of the inline box) of the HTMLElement

npm version test status

Demo

Examples

<script type="module">
import HtmlElementText from './dist/HtmlElementText.js';

for (const textElement of document.querySelectorAll('.js-text-width')) {
  const htmlElementText = new HtmlElementText(textElement);
  console.debug(`${htmlElementText.getWidth()}px`);
}
</script>

<span class="js-text-width">Hello world!</span>

Constructor

new HtmlElementText(
  thisElement: HTMLElement
)

Parameters

thisElement [required]
Target element

Methods

getWidth(text = <string>this.#thisElement.textContent): number
Get the text width (the width of that inline box)

Readme

Keywords

none

Package Sidebar

Install

npm i @saekitominaga/htmlelement-text

Weekly Downloads

0

Version

1.2.6

License

MIT

Unpacked Size

40.3 kB

Total Files

7

Last publish

Collaborators

  • saekitominaga