0

how to click cq-toggle element dynamically using javascript? When i click manually on cq-toggle menu item it actually adds active class to the element cq-toggle and add one div content in document HTML. I want to click cq-toggle dynamically using javascript.

<div class="ciq-menu-section">
    <div class="ciq-dropdowns">
        <cq-toggle class="ciq-DT tableview-ui" cq-member="tableView">
              <span></span>
              <cq-tooltip>
                 <translate original="Table View">Table View</translate>
              </cq-tooltip>
        </cq-toggle>

I have tried

 const tableViewToggle = frameDocument.querySelector(".tableview-ui")
 tableViewToggle.click();

also

tableViewToggle.classList.toggle('active');

but it is not working.

3
  • not sure what you're trying to do Commented Aug 31, 2024 at 19:32
  • i want to click cq-toggle using javascript code. Commented Sep 1, 2024 at 3:20
  • document.querySelector(".tableview-ui").addEventListener('click', event => { event.target.classList.toggle('active') }) - try this Commented Sep 2, 2024 at 14:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.