Skip to content

Commit

Permalink
Document Element.selection - grafana/k6#3519
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Jan 17, 2024
1 parent 44a5554 commit e5b02fb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/sources/next/javascript-api/k6-html/element/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The Element object provides a similar API to the [DOM Element API](https://devel

| Method | Description |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [selection](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-html/element/element-selection) | The selection that is matching the element |
| nodeName | The name of the element. |
| nodeType | The type of the element. |
| nodeValue | The element value. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: 'Element.selection()'
excerpt: 'Retrieve the Selection matching this element.'
---

# Element.selection()

Retrieve the Selection matching this element.

Mimics `$(element)`

### Returns

| Type | Description |
| ------- | ------------------------------------ |
| Selection | The Selection mathing this element. |

### Example

{{< code >}}

```javascript
import http from "k6/http";

export default () => {
let li = http.get("https://test.k6.io").html().find("li");
li.each(function(_, element) {
let container = element.selection().closest('ul.header-icons');
console.log("li.each", container.html())
});
}

```
{{< /code >}}

0 comments on commit e5b02fb

Please sign in to comment.