In this scenario, you need to query all list items that belong to the list with id 'list'. But, exclude the ones with id 'disabled' Assign those items to the variable 'listItems' by using an appropriate selector method.Once you have completed the code below, verify it by clicking the button. The respective items should change their text.
<ul id="list">
<li>OFF</li>
<li>OFF</li>
<li>OFF</li>
<li id="disabled">OFF</li>
<li>OFF</li>
<li>OFF</li>
<li id="disabled">OFF</li>
<li>OFF</li>
</ul>
<button type="button" id="button">Click Me</button>
const button = document.getElementById('button');
const listItems = document.querySelectorAll('#list li');
button.addEventListener('click', () => {
// complete the code snippet
for (let i = 0; i < listItems.length; i++) {
if (listItems[i].id !== 'disabled') {
// toggle logic goes here
}
}
});
