Style table row when clicked

  • jubilant_courgette_93644-1322146032288796673

    Dov

    3 months 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');
    });
    });
  • lucasg-1322220286279680143

    Lucas G

    3 months 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
  • jubilant_courgette_93644-1322906454390214758

    Dov

    3 months 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.