Methods
getElementText(dom, elementString) → {Array.<{elementText: string, nodeName: string, outerHTML: string, innerHTML: string, parentElement: string}>}
Takes a document object model (dom) and a target element string and returns the text content of that element.
Parameters:
Name | Type | Description |
---|---|---|
dom |
jsdom.JSDOM | The document object model, an instance of the JSDOM class. |
elementString |
string | The HTML element to query. |
- Source:
Returns:
elementText: an array of objects containing relevant element information.
- Type
- Array.<{elementText: string, nodeName: string, outerHTML: string, innerHTML: string, parentElement: string}>
Example
```javascript
// Search the dom for div element with id 'container'.
let elementString = "div#container"
getElementText(dom,elementString)
```
This will return any text content in the container element.
getLinks(dom) → {Array.<{href: string, nodeName: string, outerHTML: string, innerHTML: string, parentElement: string}>}
Takes an instance of the JSDOM class and returns all href links.
Parameters:
Name | Type | Description |
---|---|---|
dom |
jsdom.JSDOM | The document object model, an instance of the JSDOM class. |
- Source:
Returns:
links: an array of objects containing relevant link information.
- Type
- Array.<{href: string, nodeName: string, outerHTML: string, innerHTML: string, parentElement: string}>
makeTable(dom) → {Array.<string>}
Takes an instance of the JSDOM class and returns all html tables as an array of arrays.
Parameters:
Name | Type | Description |
---|---|---|
dom |
jsdom.JSDOM | The document object model, an instance of the JSDOM class. |
- Source:
Returns:
tables
- Type
- Array.<string>