Skip to content

Commit ddb7217

Browse files
committed
add Interacting with an ElementCollection
1 parent d126dc5 commit ddb7217

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

docs/user-guide.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,12 +1082,27 @@ display(paragraphs.html)
10821082
The example above displays a list with the value of the `html` attribute for all the elements in the
10831083
`paragraphs` collection.
10841084

1085-
The same way we can read attributes, we can also set an attribute directly in the collection. For instance:
1085+
The same way we can read attributes, we can also set an attribute directly in the collection. For instance,
1086+
you can directly set the html content of all the elements in the collection
10861087

10871088
```python
1088-
paragraphs.html = "That's cool :)"
1089+
# This will change the text of all H1 elements in the page
1090+
pydom['h1'].html = "That's cool :)"
10891091
```
10901092

1093+
or perhaps change their style
1094+
1095+
```
1096+
paragraphs.style['background-color'] = 'lightyellow'
1097+
```
1098+
1099+
`ElementCollection` currently support the following attributes:
1100+
1101+
* `style`: just like in `Element`, this proxy attribute can be used to change the style of the elements in
1102+
a collection by setting the proper CSS rules, using `style` with the same API as a dictionary.
1103+
* `html`: allows to change the `html` attribute on all the elements of a collection.
1104+
* `value`: allows to change the `value` attribute on all the elements of a collection.
1105+
10911106

10921107
## Workers
10931108

0 commit comments

Comments
 (0)