Random quote machine - Bug when switching quote

Hi all,

I’m currently trying to build a Random quote machine.

I’m building it step-by-step and I just wrote the basic JS code to change the quote on click.

However, it seems the JS code has a bug.

Indeed, everytime I click on the “refresh” icon :

  • there is a white screen for 1sec and;
  • it seems that the quote changes twice (once on click and once automatically…)

I don’t understand why…

Any help ?

Thank you :slight_smile:

It is because you are wrapping the icons with an anchor tag. The default action for an anchor tag is to load the value of the href attribute. When it is blank, the browser assumes you want to load the same page again. Remove the surrounding anchor tags (<a> and </a>) for the refresh button and your code will work.


Thank you very much for your help Randell!

Now I just have to make the icon looks like a link with css (use the pointer cursor).

Thanks once again :slight_smile: