diff options
author | GeoSot <geo.sotis@gmail.com> | 2022-04-26 19:38:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 19:38:41 +0300 |
commit | 00d45b11e7088981d52027df65bebf7f5e4c6050 (patch) | |
tree | b0ac4857b69e124a7ed066fb066477311dab8ded /site/content/docs/5.1/components/buttons.md | |
parent | 3edead4ffef40bd86c0bcb114b1f0206f66b51e8 (diff) |
Docs: update documentation js examples, using es6 (#36203)
* Docs: update components documentation using es6
* Docs: update js blocks around docs, using es6
* Docs: update components documentation using es6
* Test linter
Diffstat (limited to 'site/content/docs/5.1/components/buttons.md')
-rw-r--r-- | site/content/docs/5.1/components/buttons.md | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/site/content/docs/5.1/components/buttons.md b/site/content/docs/5.1/components/buttons.md index bacc6b23d2..fb9249e6c6 100644 --- a/site/content/docs/5.1/components/buttons.md +++ b/site/content/docs/5.1/components/buttons.md @@ -180,8 +180,7 @@ Add `data-bs-toggle="button"` to toggle a button's `active` state. If you're pre You can create a button instance with the button constructor, for example: ```js -var button = document.getElementById('myButton') -var bsButton = new bootstrap.Button(button) +const bsButton = new bootstrap.Button('#myButton') ``` {{< bs-table "table" >}} @@ -196,9 +195,8 @@ var bsButton = new bootstrap.Button(button) For example, to toggle all buttons ```js -var buttons = document.querySelectorAll('.btn') -buttons.forEach(function (button) { - var button = new bootstrap.Button(button) +document.querySelectorAll('.btn').forEach(buttonElement => { + const button = bootstrap.Button.getOrCreateInstance(buttonElement) button.toggle() }) ``` |