Code-pen auto-refreshing problem

I’m working on the Random Quote Generator problem and here’s where I currently am.

I’m not onto the API bit of the challenge. I’ve just managed to figure out what needs to go where in codepen. When I click on the ‘New Quote’, it changes the text as I was expecting, but then codepen autorefreshes or something (even though I disabled autorefresh.

Can someone help explain why this is happening? How do I get it to stop autorefreshing?

I’m on my phone so I can’t check your code, but it might be because you’re not using preventDefault().

Hi @strickvl

The problem is that you’ve wrapped the new quote button in an anchor tag. Because it has a href attribute, it’s trying to follow that link, which in this case it’s blank so appears to be refreshing.

You don’t really need it wrapped in an anchor tag so easiest fix is just to remove it:

// Before:
<a href="">
<button type="button" class="btn btn-primary" id="getMessage"><b>New Quote</b></button>
</a>

// After
<button type="button" class="btn btn-primary" id="getMessage"><b>New Quote</b></button>
2 Likes