JavaScript Foundation 5: call js function from topbar dropdown anchor

Maybe I am being stupid here but I cannot figure out how to respond to a Foundation 5 TopBar dropdown selection with a javascript function. I would like to select a theme for a library I use. To set the theme I need to call a js function.

What I have is:

<div class="fixed">
<nav class="top-bar" data-topbar role="navigation">
    <section class="top-bar-section">
        <!-- Right Nav Section -->
    <ul class="right">
        <li class="has-dropdown">
            <a target='_blank' href="#">Theme</a>
            <ul class="dropdown" id="theme-dropdown">
                <li><a target='_blank' href="#">Light</a></li>
                <li><a target='_blank' href="#">Dark</a></li>
            </ul>
        </li>
    </ul>
    </section>
</nav>
</div>

these are of course contained in the topbar <nav>, etc and the dropdown on the topbar works great in basic HTML mode.

What I am struggling with is how do I make the 2 <li><a> elements (light and dark themes) call my JavaScript function setTheme(themeName) when they are clicked?

I cannot seem to find any examples where someone wants to call js from a topbar rather than a URL.

Answer:1

I created a class which sets up a pausable rxjs observable on an interval: export class RepeatingServiceCall<T> { private paused = false; private observable: Observable<T>; ...

I created a class which sets up a pausable rxjs observable on an interval: export class RepeatingServiceCall<T> { private paused = false; private observable: Observable<T>; ...

  1. restart timer rxjs

I'm trying to scrap some information from this ASP page http://laredoute.fr/ppdp/prod-350007615.aspx mainly the first 4 images in high resolution that load in the image-carousel. Depending on the ...

I'm trying to scrap some information from this ASP page http://laredoute.fr/ppdp/prod-350007615.aspx mainly the first 4 images in high resolution that load in the image-carousel. Depending on the ...

  1. scrapy javascript pagination
  2. scrapy javascript support
  3. scrapy javascript click
  4. scrapy javascript onclick
  5. scrapy javascript site
  6. scrapy javascript generated content
  7. scrapy javascript rendered pages
  8. scrapy javascript link
  9. scrapy javascript next page
  10. scrapy javascript python
  11. scrapy javascript example
  12. scrapy javascript selenium
  13. scrapy javascript website
  14. scrapy javascript variable
  15. scrapy javascript button
  16. scrapy javascript form
  17. scrapy javascript table
  18. scrapy javascript postback
  19. scrapy javascript ajax
  20. scrapy javascript text

I was working on a small JavaScript project to make a tile based game (not homework, don't worry!), however I ran into a problem with my 'tile' class. Each 'tile' has an X and a Y property, for its X ...

I was working on a small JavaScript project to make a tile based game (not homework, don't worry!), however I ran into a problem with my 'tile' class. Each 'tile' has an X and a Y property, for its X ...

I'm using Ramda as my functional programming helper library to build a React app. I'm trying to build myself whereAny. Ramda exposes where which checks if every prop it is given satisfies the ...

I'm using Ramda as my functional programming helper library to build a React app. I'm trying to build myself whereAny. Ramda exposes where which checks if every prop it is given satisfies the ...