Style table row when clicked

  • Dov

    19 days ago

    Hi.

    I want to style a table row when it is clicked. I could use the following JS, but would rather to it in native toddle. Plus I don't know how I could use a conditional style using this.


    document.querySelectorAll('.table-row').forEach(row => {
    row.addEventListener('click', () => {
    // Remove 'clicked' class from all rows
    document.querySelectorAll('.table-row').forEach(r => r.classList.remove('clicked'));

    // Add 'clicked' class to the selected row
    row.classList.add('clicked');
    });
    });
  • Lucas G

    18 days ago

    You’d have to use a variable to track whether or not to activate the class
  • Unless there’s something other than a click which could control the logic
  • Dov

    16 days ago

    Thanks.

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.