Help with my random quote machine

I can not set the first quote. It works after you click next but when the page loads I don’t know how to do. Please give me a hint, here is my project

Hey, if you place all the code that is executed when you click the button in a separate function, you can call the function:

  • when the event is triggered
  • directly when the page is loaded

You could also add $(".next").trigger("click"); after your event listener. This will trigger the event and indirect the code inside the event handler.

I tried it but obviously i did something wrong. I have to put from the getJSON part or first close the document ready function?

You have to include the getJSON part. You can put the function outside the document ready function, but it I believe it shouldn’t matter. Here is a working pen:

Thank you very much I was messing it when I called my functions :grin:

1 Like