I am working on a project in CodePen editor. My problem is: How to change the text of a element each time a hit the button ?
I have an array from which I am displaying random text on a div. Thanks!
Try this:
let quots = [
'quot1',
'quot2',
//...
];
$(document).on('click', '#button', function(){
$('#quotBox').text(quots[Math.floor(Math.random() * quots.length)]);
});