Random Quote Machine, need feedback

See the Pen Random Quote by Eldar (@eldarm) on CodePen.

looks simple, doesn’t work from first click, donot why, if could anyone fix

When you submit a form it reloads the page. When an event listener calls a function it passes in an event argument. One of the methods, preventDefault, will stop the page from reloading. NOTE: $().submit is just shorthand for specific type of event.

function foo(e){ // e is automatically passed in as an argument from event listener
    e.preventDefault(); // This will prevent the page from reloading
    //  Do Stuff
}

$("#element").on("click", foo);
2 Likes

changed letter by letter as you said, Thanks a lot for help @Matthew-Keating