In HTML, button cannot be a descendant of button
Warning
This post is more than a year old. Information may be outdated.
function findNestedButtons(element = document.body) {
const buttons = element.querySelectorAll('button')
buttons.forEach((button) => {
const nestedButtons = button.querySelectorAll('button')
if (nestedButtons.length > 0) {
console.log('Found nested button:', button)
console.log('Nested buttons:', nestedButtons)
}
})
}
findNestedButtons()
Backlinks (1)