extract-html-id

1.0.0 • Public • Published

extract-html-id stability

npm version build status downloads js-standard-style

Extract all ids from html

Usage

var extract = require('extract-html-id')
var assert = require('assert')
 
var html = `
  <div id="foo">
    <p id="bar">hello planet</p>
  </div>
`
var expected = [ 'foo', 'bar']
assert.deepEqual(extract(html), expected, 'array was same')

API

ids = extract(html)

Get an array of ids for the given string. Uses a regex so safe to run on non-html strings too. Returns the first ID per DOM element. Returns an empty array if no matches are found.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i extract-html-id

Weekly Downloads

25

Version

1.0.0

License

MIT

Last publish

Collaborators

  • s3ththompson