Skip to content

Commit 2faaf59

Browse files
committed
add create element section
1 parent 684e323 commit 2faaf59

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/user-guide.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,33 @@ __ADD DIAGRAM HERE__
970970

971971
###### Creating a new element
972972

973+
New elements can be created by using the `pydom.create` method and passing the type of element
974+
being crated. Here's an example of what it looks like:
973975

976+
(To execute and explore the following code, click on the "load" button. The result will be
977+
conveniently displayed in the box on the below of the code example)
978+
979+
```python
980+
from pyweb import pydom
981+
982+
# Creating an element directly from pydom creates an unbounded element.
983+
new_div = pydom.create("div")
984+
985+
# Creating an element from another element automatically creates that element
986+
# as a child of the original element
987+
new_p = new_div.create("p", classes=["code-description"], html="Ciao PyScripters!")
988+
989+
# elements can be appended to any other element on the page
990+
pydom['#element-creation-example'][0].append(new_div)
991+
```
992+
993+
<div>
994+
<h3>Result will go here</h3>
995+
<div id="pydom-element-createion-example"></div>
996+
</div>
997+
998+
999+
For more details about `pydom.create` please refer to its reference documentation.
9741000

9751001

9761002
## Workers

0 commit comments

Comments
 (0)