aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaĆ«l Poupard <[email protected]>2021-05-18 07:31:15 +0200
committerGitHub <[email protected]>2021-05-18 08:31:15 +0300
commit83bcc3c00f0d1fb166324f9f3ac8f4a9f3eee323 (patch)
tree5ef1080fb7acf6394be98568c5be2a9c1de0a63e
parent58b1be927f43c779377e478df2d119f2ddf956ca (diff)
downloadbootstrap-83bcc3c00f0d1fb166324f9f3ac8f4a9f3eee323.tar.xz
bootstrap-83bcc3c00f0d1fb166324f9f3ac8f4a9f3eee323.zip
docs(cheatsheet): fix JS errors in `setActiveItem()` (#34011)
-rw-r--r--site/content/docs/5.0/examples/cheatsheet/cheatsheet.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/site/content/docs/5.0/examples/cheatsheet/cheatsheet.js b/site/content/docs/5.0/examples/cheatsheet/cheatsheet.js
index 541cf9350..0a50258b9 100644
--- a/site/content/docs/5.0/examples/cheatsheet/cheatsheet.js
+++ b/site/content/docs/5.0/examples/cheatsheet/cheatsheet.js
@@ -25,8 +25,8 @@
toast.show()
})
- // Disable empty links
- document.querySelectorAll('[href="#"]')
+ // Disable empty links and submit buttons
+ document.querySelectorAll('[href="#"], [type="submit"]')
.forEach(function (link) {
link.addEventListener('click', function (event) {
event.preventDefault()
@@ -41,6 +41,11 @@
}
var link = document.querySelector('.bd-aside a[href="' + hash + '"]')
+
+ if (!link) {
+ return
+ }
+
var active = document.querySelector('.bd-aside .active')
var parent = link.parentNode.parentNode.previousElementSibling